AngularJS: Filter ng-options not having specific values

AngularJS NOT Filter <select ng-model=”test” ng-options=”c as c.label group by c.type for c in columns | filter:{ type : ‘!field’ } | filter:{ type : ‘!map’ }”> </select> Fiddle From the docs: “…The predicate can be negated by prefixing the string with !.” “A pattern object can be used to filter specific properties on objects … Read more

Why AngularJS currency filter formats negative numbers with parenthesis?

I know this is an old question, but the accepted answer is only answering why this happens, without a concrete solution to the problem. I think the “most correct way” of doing this, is to use a decorator like so: angular .module(‘app’) .config([‘$provide’, function($provide) { $provide.decorator(‘$locale’, [‘$delegate’, function($delegate) { if($delegate.id == ‘en-us’) { $delegate.NUMBER_FORMATS.PATTERNS[1].negPre=”-\u00A4″; $delegate.NUMBER_FORMATS.PATTERNS[1].negSuf=””; … Read more

Filtering an ng-repeat list based on a sub-object property

You are allowed to create new scope members inside the expressions. This lets you assign a filtered list to a new variable, which can be used throughout the local scope. With that, you can pass the length of the filtered list to ng-show: <body ng-app> <div ng-controller=”Ctrl”> <div class=”daily” ng-repeat=”daily in dailies | orderBy:’-date’ ” … Read more

Angularjs OrderBy on ng-repeat doesn’t work

$scope.teams isn’t an array (it’s an object of objects), and the orderBy filter only works with arrays. If you make $scope.teams an array, it will work: $scope.teams = [ { id: 100, name: “team1”, count_win: 3, count_loose: 2, goal_average: 2, }, { id: 200, name: “team2”, count_win: 3, count_loose: 2, goal_average: 1, }, { id: … Read more

AngularJS ‘ng-filter’ is very slow on array of ~1000 elements

The main problem with the filter approach is that upon each change the dom is manipulated, so it’s not the filter that’s slow but the consequences. An alternative is to use something like: ng-show=”([item] | filter:searchFilter).length > 0″ on the repeated element. Lending some code from @OverZealous, you can use the following to compare the … Read more

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)