Совместимость браузера начиная с Internet Explorer 8 и Firefox 3.6.
Есть несколько способов добавить необходимые файлы:
расположение скриптов
Для поддержки IE8 / FF3.6 необходимо подключить:
<!-- IE8 support, see AngularJS Internet Explorer Compatibility http://docs.angularjs.org/guide/ie For Firefox 3.6, you will also need to include jQuery and ECMAScript 5 shim --> <!--[if lt IE 9]> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.js"></script> <script src="http://cdnjs.cloudflare.com/ajax/libs/es5-shim/2.2.0/es5-shim.js"></script> <script> document.createElement('ui-select'); document.createElement('ui-select-match'); document.createElement('ui-select-choices'); </script> <![endif]-->
Для RequireJS ваша установка может выглядеть так:
require.config({ paths: { 'angular': 'bower_components/angular/angular', 'angular-ui-select': 'bower_components/angular-ui-select/dist/select' }, shim: { 'angular-ui-select': ['angular'] } });
Включите в свое приложение модули ui.select и ngSanitize
var module = angular.module('myapp', ['ui.select', 'ngSanitize']);
Основное использование директивы в html
<ui-select ng-model="selected.value"> <ui-select-match> <span ng-bind="$select.selected.name"></span> </ui-select-match> <ui-select-choices repeat="item in (itemArray | filter: $select.search) track by item.id"> <span ng-bind="item.name"></span> </ui-select-choices> </ui-select>
С соответствующим angular controller:
angular.module('app') .controller('ctrl', ['$scope', function ($scope){ $scope.itemArray = [ {id: 1, name: 'first'}, {id: 2, name: 'second'}, {id: 3, name: 'third'}, {id: 4, name: 'fourth'}, {id: 5, name: 'fifth'}, ]; $scope.selected = { value: $scope.itemArray[0] }; }]);