Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. <select ng-model="filtro.galpao" chosen id="BuscarGalpaoId">
  2. <option selected="selected" value="">Selecione um Galpão</option>
  3. <option ng-repeat="galpao in selectList.galpoes"
  4. ng-class="{
  5. incompleto: galpao.situacao === 'incompleto',
  6. completo: galpao.situacao === 'completo',
  7. vazio: galpao.situacao === 'vazio',
  8. inativo: galpao.situacao === 'inativo'
  9. }" value="{{galpao.id}}">{{galpao.descricao}}
  10. </option>
  11. </select>
  12.  
  13. app.directive('chosen', function ($timeout) {
  14. var linker = function (scope, elemen, attrs) {
  15. // update the select when data is loaded
  16. scope.$watch(attrs.select2, function (oldVal, newVal) {
  17. $timeout(function () {
  18. elemen.trigger('change');
  19. }, 100);
  20. });
  21.  
  22. // update the select when the model changes
  23. scope.$watch(attrs.ngModel, function () {
  24. $timeout(function () {
  25. elemen.trigger('change');
  26. }, 100);
  27. });
  28.  
  29. angular.element(elemen).select2({width: '100%'});
  30. };
  31.  
  32. return {
  33. restrict: 'A',
  34. link: linker
  35. };
  36. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement