javascript - AngularJS : Creating custom filter for decimal points -


i trying convert below js code re-usable angularjs filter

var = 1.1230000,     b = a.tofixed(15).replace(/\.?0+$/, "");  // ==> 1.123 

i have created below code(angularjs)

  angular.module('myapp.filters', []).filter('fixed', [function () {     return function(input) {       return input = input.tofixed(15).replace(/\.?0+$/, "");     };   }]); 

and invoked new filter module

var myapp = angular.module('myapp', ['fixed']); 

but displays error: [$injector:modulerr] http://errors.angularjs.org/1.2.16/$injector/modulerr?p0=myapp&p1=%5b%24injector%3amodulerr%5d%20http%3a%2f%2ferrors.angularjs.org%.........

am missing , sorry mistake. help.

update - added jsbin url

you don't need inject components part of module. myapp.filter('filtertofixed in module myapp.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -