Skip to content

Instantly share code, notes, and snippets.

@eduavila
Created March 14, 2016 13:56
Show Gist options
  • Select an option

  • Save eduavila/2d52c0da9a5e7248c636 to your computer and use it in GitHub Desktop.

Select an option

Save eduavila/2d52c0da9a5e7248c636 to your computer and use it in GitHub Desktop.
pf-combox
.directive('pfComobox', ["$timeout", function ($timeout) {
'use strict';
return {
restrict: 'A',
require: '?ngModel',
scope: {
selectPickerOptions: '=pfCombobox'
},
link: function (scope, element, attrs, ngModel) {
var optionCollectionList, optionCollection, $render = ngModel.$render;
element.combobox(scope.selectPickerOptions);
ngModel.$render = function () {
$render.apply(this, arguments);
$timeout(function () {
element.combobox('refresh');
}, 0, false);
};
if (attrs.ngOptions) {
optionCollectionList = attrs.ngOptions.split('in ');
optionCollection = optionCollectionList[optionCollectionList.length - 1];
scope.$watchCollection(optionCollection, function () {
element.combobox('refresh');
});
}
scope.$watch('ngModel',function(){
console.log('reload');
$timeout(function () {
element.combobox('refresh');
},300);
});
attrs.$observe('disabled', function () {
element.combobox('refresh');
});
}
};
}]);
@eduavila
Copy link
Author

Selecione

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment