Created
January 24, 2015 16:31
-
-
Save deitch/e4abbaeeaca7b0d66fcf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// directive | |
.directive('resetSearchModel',function () { | |
return { | |
restrict: 'A', | |
require: ['^ngModel','uiSelect'], | |
link: function (scope, element, attrs, ctrls) { | |
if (attrs.resetSearchModel === "true" || attrs.resetSearchModel === true) { | |
scope.$watch(attrs.ngModel,function (newval,oldval,scope) { | |
scope.$select.selected = undefined; | |
}); | |
} | |
} | |
}; | |
}) | |
// sample usage - see: 'reset-search-model="true"' | |
<ui-select ng-model="myModel" theme="bootstrap" on-select="searchselect($item)" reset-search-input="true" reset-search-model="true"> | |
<ui-select-match placeholder="Search...">{{$select.selected.name}}</ui-select-match> | |
<ui-select-choices refresh="search({val:$select.search})" refresh-delay="300" repeat="item in results"> | |
<div ng-bind="item.name"></div> | |
</ui-select-choices> | |
</ui-select> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment