Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.min.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body ng-app="test" ng-controller="Test">
  <select ng-options="opt.id as opt.name for opt in options | orderBy: 'id'" ng-model="selected" multiple></select>
</body>
</html>
 
angular.module("test", [])
.controller("Test", function($scope) {
  var rawOptions = {
    1: {name: 'apple', id: 1},
    5: {name: 'orange', id: 5},
    3: {name: 'pear', id: 3},
    7: {name: 'mango', id: 7}
  }
  
  var rawSelected = [
    3, 5
  ]
  
  $scope.options = rawOptions;
  $scope.selected = rawSelected;
})
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers