I am going through the Angularjs tuts and docs given in the official angularjs website.
Here we add a selectbox for ordering, like this
<select ng-model="orderProp">
<option value="name">Alphabetical</option>
<option value="age">Newest</option>
</select>
and in the controller, we assign $scope.orderProp = "age" This works fine and 'Newest' will be the default select option.
Then I tried putting the order items to a model and populate the selectbox using ng-repeat like this.
<select ng-model="orderProp">
<option ng-repeat="orderby in orderProperties" value="{{orderby.criteria}}">{{orderby.property}}</option>
</select>
where:
orderProp model is :
function PhoneListCtrl($scope){
$(document).ready($scope.orderProp = "age");
$scope.orderProperties = [
{"property":"Alphabetical","criteria":"name"},
{"property":"Newest","criteria":"age"}
];
}
In dom I can see the value="name" and value="age". But this time the default value is not set as "Newest". I don't understand why the hardcoded value="age" is working, while value="{{orderby.criteria}}" is not. Can anyone please guide me through.
$scope.orderProp = "age"and sorting is getting triggered. But the selectbox<select ng-model="orderProp">is still empty. I am assuming it might be due something like assigning value before page load or something like that and might not be related to angularjs.select. And you don't need$(document).ready(...).