Skip to content

Instantly share code, notes, and snippets.

@shalotelli
Last active August 29, 2015 14:13
Show Gist options
  • Save shalotelli/81dfef11779246cdb0e2 to your computer and use it in GitHub Desktop.
Save shalotelli/81dfef11779246cdb0e2 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<link data-require="[email protected]" data-semver="3.2.0" rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" />
<script data-require="[email protected]" data-semver="2.1.1" src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script data-require="[email protected]" data-semver="1.3.0-beta.5" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.5/angular.min.js"></script>
<script src="multiselect.js"></script>
<link rel="stylesheet" href="styles/multi-select.css" />
</head>
<body ng-app="multiSelectDemo">
<div class="container">
<h1>Shalotelli Angular Multiselect</h1>
<div ng-controller="MainCtrl">
<div class="row">
<div class="col-xs-6">
<multi-select
name="test"
values="multiSelectData"
model="selectedItems"
show-filters="true"
value-field="id"
label-field="label"
template-path="views/directives/multi-select.html">
</multi-select>
</div>
</div>
<hr />
<p>Multi Select Data: </p>
<pre>{{multiSelectData}}</pre>
<p></p>
<hr />
<p>Multi Select Output: </p>
<pre>{{selectedItems}}</pre>
<hr>
<p>
<button class="btn btn-primary" ng-click="selectSomeManually()">
Select Some Manually
</button>
</p>
</div>
</div>
<script>
(function () {
'use strict';
angular.module('multiSelectDemo', [ 'shalotelli-angular-multiselect' ])
.controller('MainCtrl', [ '$scope', function ($scope) {
$scope.multiSelectData = [
{ id: 1, label: 'Customer Name #1' },
{ id: 2, label: 'Customer Name #2' },
{ id: 3, label: 'Customer Name #3' },
{ id: 4, label: 'Customer Name #4' },
{ id: 5, label: 'Customer Name #5' },
{ id: 999, label: 'Other', isOther: true}
];
$scope.selectedItems = [
{ id: 1, label: 'Customer Name #1' },
{ id: 2, label: 'Customer Name #2' }
];
$scope.manualSelect = [
{ id: 3, label: 'Customer Name #3' }
];
$scope.multiSelectOutput = [];
$scope.selectSomeManually = function () {
$scope.$broadcast('multiSelectManualUpdate', 'test', $scope.manualSelect);
}
}]);
})();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment