SO - Select OrderByIssue
http://stackoverflow.com/questions/22938958/does-orderby-only-work-the-first-time-with-ng-options
by ncapito
HTML
<div ng-controller="MyCtrl">
<select multiple='' ng-options="thing as thing.display for thing in mythings | orderBy:'display'" ng-model="selectedThings"></select>
<div>
<input ng-model="model.display" />
<input ng-model="model.shade" />
<button ng-click="add()">Add To basket</button>
</div>
</div>
CSS
select{
height: 150px;
margin-bottom: 10px;
}
JavaScript
var myApp = angular.module('myApp', []);
function MyCtrl($scope, $timeout) {
$scope.mythings = [{
display: 'black',
shade: 'dark'
}, {
display: 'white',
shade: 'light'
}, {
display: 'red',
shade: 'dark'
}, {
display: 'blue',
shade: 'dark'
}, {
display: 'yellow',
shade: 'light'
}];
$scope.selectedThings = [];
$scope.add = function () {
$timeout(function () {
$scope.mythings.push($scope.model);
$scope.model = {};
});
}
}