angularjs - select multiple
http://angularjs.org/
HTML
<script src="http://code.angularjs.org/angular-1.0.1.js"></script>
<script src="https://raw.github.com/ivaynberg/select2/master/select2.js"></script>
<link rel="stylesheet" href="https://raw.github.com/ivaynberg/select2/master/select2.css">
<div ng-controller="controller">
<select
ng-change="selectAction()"
ng-model="myModel"
ng-click="initSelect()"
ng-options="value.value as value.label for value in myOptions">
<option>--</option>
</select>
<div ng-repeat="option in myOptions">
<p ng-bind="option.label" />
</div>
</div>
JavaScript
var myApp = angular.module('myApp', []);
myApp.controller('controller', ['$scope', '$http', '$window', '$location', '$timeout', function ($scope, $http, $window, $location, $timeout) {
$scope.myOptions = [];
$scope.selectInitialized = false;
$scope.myOptions[0] = {
value: 'all-init',
label: 'Group...'
};
$scope.myOptions[1] = {
value: 'all',
label: 'All'
};
$scope.myOptions[2] = {
value: 'admins',
label: 'Admins'
};
$scope.myModel = $scope.myOptions[0].value;
$scope.initSelect = function () {
if ($scope.selectInitialized === false)
{
$scope.myOptions = $scope.myOptions.splice(1, 2)
$scope.selectInitialized = true;
$scope.myModel = $scope.myOptions[0].value;
}
};
}]);