Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <select>
- <option data-subtext="Mustard's yellow" >Mustard</option>
- <option data-subtext="Ketchup's red">Ketchup</option>
- <option data-subtext="I don't know about Relish">Relish</option>
- </select>
- $('select').selectpicker({showSubtext:true});
- <select ng-model="idCourse" class="form-control input-sm" data-live-search="true" select-picker>
- <option ng-repeat="c in cources" value="{{c.id}}" data-subtext="{{c.name}}">{{c.code}}</option>
- </select>
- angular.module('myApp', [])
- .controller('ctrl',['$scope', function($scope){
- $scope.courses = [
- {id:1, code:'CS1607', name:'computer science beginner'},
- {id:2, code:'PH006', name:'Quantum physics'},
- {id:3, code:'CSB-9', name:'Machine Learning'}
- ];
- }])
- .directive('selectPicker', function(){
- return {
- restrict: 'A',
- link:function(scope, elem){
- elem.selectpicker({showSubtext:true});
- }
- };
- });
- //omitted...
- .directive('selectPicker', ['$timeout', function($timeout){
- return {
- restrict: 'A',
- link:function(scope, elem){
- $timeout(function() {
- elem.selectpicker({showSubtext:true});
- }, 0);
- }
- };
- }]);
- function MyCtrl($scope) {
- angular.element(document).ready(function () {
- $('select').selectpicker({showSubtext:true});
- });
- }
- angular.element(document).ready(function () { $('select').selectpicker("destroy"); $('select').selectpicker("render"); });
Add Comment
Please, Sign In to add comment