AngularJS : ng-repeat filter when value is greater than

Create a predicate function on the relevant scope: $scope.greaterThan = function(prop, val){ return function(item){ return item[prop] > val; } } As a first argument, it takes a property name on the object. The second argument is an integer value. Use it in your view like this: <tr ng-repeat-start=”list in Data.Items | filter: greaterThan(‘NumberOfStamps’, 0)”> Demo

AngularJS – multiple ng-click – event bubbling

This solution worked for me (I’m only supporting recent browsers, so I tried to modify the code to be more retro-compatible): HTML: <li ng-repeat=”item in items” ng-click=”showItem(item)”> <h3>{{item.title}}</h3> <button ng-click=”remove(item, $event)”>Remove</button> </li> Scripts: function remove(item, $event) { // do some code here // Prevent bubbling to showItem. // On recent browsers, only $event.stopPropagation() is needed … Read more

nested ng-repeat $parent.$index and $index

DEMO FIDDLE That’s because the directive ng-if creates a new scope for itself, when you refer to $parent, it access the immediate $parent‘s scope, i.e., the inner repeat expression’s scope. So if you want to achieve something you wanted like in the former, you may use this: <div ng-repeat=”i in list”> <div ng-repeat=”j in list2″> … Read more

How to $watch changes on models created by ng-repeat?

Create individual list-item controllers: demo on Plnkr js angular .module(‘testApp’, []) .controller(‘testCtrl’, function ($scope) { $scope.fooCollection = []; }) .controller(‘fooCtrl’, function ($scope) { $scope.$watch(‘’, function (newValue, oldValue) { console.log(‘watch fired, new value: ‘ + newValue); }); }); HTML <html ng-app=”testApp”> <body ng-controller=”testCtrl”> <div ng-repeat=”(fooKey, foo) in fooCollection” ng-controller=”fooCtrl”> Tell me your name: <input ng-model=”” ng-change=”doSomething()”> … Read more

How to generates dynamically ng-model=”my_{{$index}}” with ng-repeat in AngularJS?

Does it solve your problem? function MainCtrl($scope) { $scope.queryList = [ { name: ‘Check Users’, fields: [ “Name”, “Id”] }, { name: ‘Audit Report’, fields: [] }, { name: ‘Bounce Back Report’, fields: [ “Date”] } ]; $scope.models = {}; $scope.$watch(‘selectedQuery’, function (newVal, oldVal) { if ($scope.selectedQuery) { $scope.parameters = $scope.selectedQuery.fields; } }); } And … Read more

Angular passing scope to ng-include

Late to the party, but there is a little angular ‘hack’ to achieve this without implementing a dumb directive. Adding a built-in directive that will extend your controller’s scope (like ng-if) everywhere you use the ng-include will actually let you isolate the variable name for all the included scopes. So: <div ng-include=”‘item.html'” ng-if=”true” onload=”item = … Read more

Binding inputs to an array of primitives using ngRepeat => uneditable inputs

Can anyone explain to me why are the inputs uneditable/readonly? If it’s by design, what’s the rationale behind? It is by design, as of Angular 1.0.3. Artem has a very good explanation of how 1.0.3+ works when you “bind to each ng-repeat item directly” – i.e., <div ng-repeat=”num in myNumbers”> <input type=”text” ng-model=”num”> When your … Read more