I am following tutorial for Angular JS on their website.
Instead of the dropdown for selecting the order[Alphabetically or Newest], I made two buttons for it and defined ng-click on them.
Here is my code:
HTML Partial CODE:
<nav class="top-bar" data-topbar>
<ul class="title-area">
<li class="name">
<h1><a href="#">My Site</a></h1>
</li>
<li class="toggle-topbar menu-icon"><a href="#">Menu</a></li>
</ul>
<section class="top-bar-section">
<ul class="right">
<li>Sort by: </li>
<li class="active"><a href="#" ng-click="setOrder('age')">Newest</a></li>
<li><a href="#" ng-click="setOrder('name')">Alphabetical</a></li>
</ul>
<ul class="left">
<li class="divider"></li>
<li class="has-form">
<input type="text" ng-model="query" placeholder="Find Stuff"> </li>
</ul>
</section>
</nav>
<div class="row">
<ul class="phones">
<li ng-repeat="phone in phones | filter: query | orderBy: orderProp" class="thumbnail">
<a href="#/phones/{{phone.id}}" class="thumb"><img src="" alt="" ng-src="{{phone.imageUrl}}"></a>
<a href="#/phones/{{phone.id}}" class="thumb">{{phone.name}}</a>
<p>{{phone.snippet}}</p>
</li>
</ul>
</div>
AND MY CONTROLLER:
phonecatControllers.controller('PhoneListCtrl', ['$scope', 'Phone', function($scope, Phone) {
$scope.phones= Phone.query();
$scope.orderProp= 'age';
$scope.setOrder= function(order) {
$scope.orderProp= order.toString();
}
}]);
Routers:
phonecatApp.config(['$routeProvider',
function($routeProvider) {
$routeProvider.
when('/phones', {
templateUrl: 'partials/phone-list.html',
controller: 'PhoneListCtrl'
}).
when('/phones/:phoneId', {
templateUrl: 'partials/phone-details.html',
controller: 'PhoneDetailCtrl'
}).
otherwise({
redirectTo: '/phones'
});
}]);
Setorder function is being called when I am clicking on Link, however I cannot see changes in Order listing.
What I am doing wrong here?