Removing AngularJS currency filter decimal/cents

Update: as of version 1.3.0 – currencyFilter: add fractionSize as optional parameter, see commit and updated plunker {{10 | currency:undefined:0}} Note that it’s the second parameter so you need to pass in undefined to use the current locale currency symbol Update: Take note that this only works for currency symbols that are displayed before the … Read more

Angular.js ng-repeat filter by property having one of multiple values (OR of values)

Best way to do this is to use a function: <div ng-repeat=”product in products | filter: myFilter”> $scope.myFilter = function (item) { return item === ‘red’ || item === ‘blue’; }; Alternatively, you can use ngHide or ngShow to dynamically show and hide elements based on a certain criteria.

How to unit test a filter in AngularJS 1.x

Inject $filter and then call it with $filter(‘filterName’)(input, options); So to test the equivalent of this template {{ foo | testFilter:capitalize }} describe(‘The test filter’, function () { ‘use strict’; var $filter; beforeEach(function () { module(‘myTestFilterModule’); inject(function (_$filter_) { $filter = _$filter_; }); }); it(‘should capitalize a string’, function () { // Arrange. var foo … Read more

Angularjs filter not null

Angular >=1.3.16 to latest (1.5.5 at time of writing/update) use ” (empty string) (or ‘!!’ also works) <ul> <li ng-repeat=”detail in details | filter:{shortDescription: ”}”> <p>{{detail.shortDescription}}</p> </li> </ul> Example: http://jsfiddle.net/TheSharpieOne/1mnachk6/ Angular >=1.3.6 and <=1.3.15 use ‘!null’ <ul> <li ng-repeat=”detail in details | filter:{shortDescription: ‘!null’}”> <p>{{detail.shortDescription}}</p> </li> </ul> Example: http://jsfiddle.net/TheSharpieOne/4wxs67yv/ Angular >=1.2 and <=1.3.5 use ” … Read more

angularjs force uppercase in textbox

Please see the other answer below, which is superior to this one. this answer is based on the answer here: How to autocapitalize the first character in an input field in AngularJS?. I’d imagine that what you’d want would be a parser function like this: angular .module(‘myApp’, []) .directive(‘capitalize’, function() { return { require: ‘ngModel’, … Read more