Guest User

Untitled

a guest
Nov 19th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. <select>
  2. <option data-subtext="Mustard's yellow" >Mustard</option>
  3. <option data-subtext="Ketchup's red">Ketchup</option>
  4. <option data-subtext="I don't know about Relish">Relish</option>
  5. </select>
  6.  
  7. $('select').selectpicker({showSubtext:true});
  8.  
  9. <select ng-model="idCourse" class="form-control input-sm" data-live-search="true" select-picker>
  10. <option ng-repeat="c in cources" value="{{c.id}}" data-subtext="{{c.name}}">{{c.code}}</option>
  11. </select>
  12.  
  13. angular.module('myApp', [])
  14.  
  15. .controller('ctrl',['$scope', function($scope){
  16. $scope.courses = [
  17. {id:1, code:'CS1607', name:'computer science beginner'},
  18. {id:2, code:'PH006', name:'Quantum physics'},
  19. {id:3, code:'CSB-9', name:'Machine Learning'}
  20. ];
  21. }])
  22.  
  23. .directive('selectPicker', function(){
  24. return {
  25. restrict: 'A',
  26. link:function(scope, elem){
  27. elem.selectpicker({showSubtext:true});
  28. }
  29. };
  30. });
  31.  
  32. //omitted...
  33. .directive('selectPicker', ['$timeout', function($timeout){
  34. return {
  35. restrict: 'A',
  36. link:function(scope, elem){
  37. $timeout(function() {
  38. elem.selectpicker({showSubtext:true});
  39. }, 0);
  40. }
  41. };
  42. }]);
  43.  
  44. function MyCtrl($scope) {
  45. angular.element(document).ready(function () {
  46. $('select').selectpicker({showSubtext:true});
  47. });
  48. }
  49.  
  50. angular.element(document).ready(function () { $('select').selectpicker("destroy"); $('select').selectpicker("render"); });
Add Comment
Please, Sign In to add comment