Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
app.directive('currencyField', ['UserService', function (UserService) {
return {
restrict: 'E',
replace: true,
scope: {
value: '@'
},
templateUrl: "currency_field.html",
link: function (scope, element, attributes) {
UserService.getCurrentUser().$promise.then(function (response) {
scope.activeLocale = response.data.activeLocale;
switch (scope.activeLocale) {
case "nl":
debugger;
scope.formattedValue = '€ ' + attributes.get('value');
break;
case "de":
scope.formattedValue = scope.value + ' €';
break;
case "en":
scope.formattedValue = '$ ' + scope.value;
break;
default:
console.log('No active locale.');
}
});
}
}
}]);
// usage
<currency-field value="{{leadCtrl.lead.deliveryCosts}}"></currency-field>
// template
<span class="pull-right" ng-bind-html="formattedValue"></span>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.