What is assigning filter output to variables and why?
This filter is used to filter an array items using the filter expressions and store in the temporary variable which are used to latter for other purpose.
This filter is used to filter an array items using the filter expressions and store in the temporary variable which are used to latter for other purpose.
//The syntax is : <ul ng-repeat="tempItem in tempItems = {users | filter:username | orderBy: 'age' } "> <li>{{tempItem.name | uppercase }}</li> <li>{{tempItem.name | lowercase }}</li> </ul> //The example detail as given below. <!DOCTYPE html> <html> <head> <script src="https://code.angularjs.org/1.4.0-beta.6/angular.js"></script> <script> var app = angular.module("myApp", []); app.controller("MyCtrl", function ($scope) { $scope.users = [{ name: "Anil Singh", age: 30 }, { name: "Sunil", age: 20 }, { name: "Viru Da", age: 40 }, { name: "Aradhya", age: 1 }]; }); </script> </head> <body ng-app="myApp"> <div ng-controller="MyCtrl"> <div class="form-inline"> <input ng-model="username" type="text" placeholder="Flter key"> </div> <ul ng-repeat="tempItem in tempItems = {users | filter:username | orderBy: 'age' } "> <li>{{tempItem.name | uppercase }}</li> <li>{{tempItem.name | lowercase }}</li> </ul> </div> </body> </html>The output as below,
Blogger Comment
Facebook Comment