<body ng-app="phonecatApp" ng-controller="PhoneListCtrl"> Search: <input ng-model="query"> Sort by: <select ng-model="orderProp"> <option value="name">Alphabetical</option> <option value="age">Newest</option> </select> <ul class="phones"> <li ng-repeat="phone in phones | filter:query | orderBy:orderProp"> <span>{{phone.name}}</span> <p>{{phone.snippet}}</p> </li> </ul> </body>
var phonecatApp = angular.module('phonecatApp',[]); phonecatApp.controller('PhoneListCtrl',function($scope){ $scope.phones =[ {'name':'Nexus S','snippet':'Fast just got faster with Nexus S.','age':1}, {'name':'Motorola XOOMâ„¢ with Wi-Fi','snippet':'The Next, Next Generation tablet.','age':2}, {'name':'MOTOROLA XOOMâ„¢','snippet':'The Next, Next Generation tablet.','age':3} ]; $scope.orderProp ='age'; });