Guest User

Untitled

a guest
Nov 19th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.16 KB | None | 0 0
  1. index.html
  2. <link href="resources/css/bootstrap.min.css" rel="stylesheet">
  3. <link href="resources/css/bootstrap-select.css" rel="stylesheet">
  4. <!-- Bootstrap Core CSS -->
  5.  
  6. <script src="resources/js/jquery-2.1.1.min.js"></script>
  7. <script src="resources/js/jquery-1.11.0.js"></script>
  8.  
  9. <script src="resources/js/bootstrap-select.js"></script>
  10.  
  11. <script src="resources/library/angular.js"></script>
  12. <script src="resources/library/angular-route.js"></script>
  13. <script src="resources/js/MainController.js"></script>
  14. <script src="resources/js/main-app.js"></script>
  15.  
  16. partialview.html
  17. -------------------
  18. <select class="selectpicker" multiple ng-model="selE">
  19. <option ng-repeat="e in ee">{{e}}</option>
  20. </select>
  21.  
  22. <script>
  23. $(document).ready(function () {
  24.  
  25. $('select').selectpicker({
  26. style: 'btn-default',
  27. size: false
  28. });
  29.  
  30. });
  31.  
  32. </script>
  33.  
  34. <select class="selectpicker"
  35. multiple
  36. title='Choose one of the following...'>
  37. <option>Mustard</option>
  38. <option>Ketchup</option>
  39. <option>Relish</option>
  40. </select>
  41.  
  42. angular.module('demo')
  43. .directive('selectpicker', function () {
  44. return {
  45. restrict: 'C',
  46. link: function (scope, element) {
  47. $(element).selectpicker({
  48. style: 'btn-default',
  49. size: false
  50. });
  51. }
  52. };
  53. });
  54.  
  55. angular.module('demo')
  56. .directive('selectpicker', function () {
  57. return {
  58. restrict: 'C',
  59. require: 'ngModel',
  60. link: function (scope, element, attrs, ngModel) {
  61. var $el = $(element);
  62. $el.selectpicker({
  63. style: 'btn-default',
  64. size: false
  65. });
  66. $el.on('change', function (ee, aa) {
  67. ngModel.$setViewValue($el.val());
  68. scope.$apply();
  69. });
  70. }
  71. };
  72. });
  73.  
  74. angular.module('demo')
  75. .controller('MainCtrl', function ($scope) {
  76. $scope.selected = [];
  77. });
  78.  
  79. <select ng-model="selected"
  80. class="selectpicker"
  81. multiple
  82. title='Choose one of the following...'>
  83. <option>Mustard</option>
  84. <option>Ketchup</option>
  85. <option>Relish</option>
  86. </select>
  87.  
  88. <select ng-model="selected"
  89. class="selectpicker"
  90. multiple
  91. title='Choose one of the following...'>
  92. <option>Mustard</option>
  93. <option>Ketchup</option>
  94. <option>Relish</option>
  95. </select>
  96.  
  97. angular.module('demo')
  98. .directive('selectpicker', function ($timeout) {
  99. return {
  100. restrict: 'C',
  101. require: 'ngModel',
  102. replace: true,
  103. template: '<select multiple><option ng-repeat="opt in options">{{ opt }}</option></select>',
  104. scope: {
  105. options: '='
  106. },
  107. link: function (scope, element, attrs, ngModel) {
  108. var $el = $(element);
  109. $timeout(function () {
  110. $el.selectpicker({
  111. style: 'btn-default',
  112. size: false
  113. });
  114. });
  115. $el.on('change', function (ee, aa) {
  116. ngModel.$setViewValue($el.val());
  117. scope.$apply();
  118. });
  119. }
  120. };
  121. });
  122.  
  123. <div ng-model="selected"
  124. class="selectpicker"
  125. options="issues"
  126. title='Choose one of the following...'>
  127. </div>
Add Comment
Please, Sign In to add comment