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

In the AngularJS BootstrapUI Typeahead, what’s $viewValue?

here is a working typeahead example: <div class=”container”> <div ng-controller=”mainCtrl” class=”row-fluid”> <form class=”row-fluid”> <div class=”container-fluid”> <input type=”text” ng-model=”selected” typeahead=”state for state in states | filter:$viewValue” /> </div> </form> </div> </div> <script> angular.module(‘myApp’, [‘ui.bootstrap’]) .controller(“mainCtrl”, function ($scope) { $scope.selected = ”; $scope.states = [‘Alabama’, ‘Alaska’, ‘Arizona’, ‘Arkansas’, ‘California’, ‘Colorado’, ‘Connecticut’, ‘Delaware’, ‘Florida’, ‘Georgia’, ‘Hawaii’, ‘Idaho’, ‘Illinois’, …

Read more

Saving new models using AngularJS and $resource

The first think you should note, that scope != model, but scope can contain model(s). You should have some object in your scope and then save it. So, there would be something like the following: HTML: <div ng-controller=”entryController”> <input type=”text” ng-model=””><br/> <textarea ng-model=”poll.description” required></textarea><br/> <button class=”btn btn-primary” ng-click=”saveEntry()”>Save</button> </div> JavaScript: function pollController($scope, $resource) { var …

Read more

After upgrading TypeScript, Angular controller registration now fails to compile

Since all of the properties of IController are optional, I believe the errors you are seeing are a result of the new checking for “Weak Types” in TypeScript 2.4. Check this link from Microsoft for details. Also check this related Github issue. Some relevant quotes from Microsoft: In TypeScript 2.4, we’re adding a similar check …

Read more