Selected option in select Angularjs -


my question simple, can't it. have select order elements in angularjs custom options. need 1 option selected when page loads.

here's code:

<select ng-model="sortby">     <option value='priceorder'>price order</option>     <option value='price'>price - +</option>     <option value='-price'>price + -</option>     <option value='weight'>weight + -</option>     <option value='-weight'>weight - +</option> </select> 

the values comes json in controller.js, , ask order in:

<li ng-repeat="item in filteredgenere | filter:query | orderby:sortby" >.    {{item.brand}} {{item.name}} </li> 

if want select box has 1 option selected when page loaded, need initialize $scope.sortby in controller

$scope.sortby = 'priceorder'; 

check demo


Comments