Created
January 7, 2015 00:46
-
-
Save howieweiner/f9db8d386a507defad2b to your computer and use it in GitHub Desktop.
Angular ui-select child directive to clear (Bootstrap) input
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
(function () { | |
'use strict'; | |
angular | |
.module('app.directives') | |
.directive('uiSelectClear', SelectClear) | |
; | |
SelectClear.$inject = ['$timeout']; | |
/** | |
* Child directive for clearing ui-select | |
*/ | |
function SelectClear($timeout) { | |
return { | |
restrict: 'EA', | |
require: '^uiSelect', | |
template: '<a class="btn btn-xs pull-right" style="margin-right:10px">X</a>', | |
replace: true, | |
link: function (scope, element, attrs, $select) { | |
element.on('click', function (e) { | |
e.stopPropagation(); | |
$timeout(function () { | |
$select.selected = undefined; | |
}); | |
}); | |
} | |
}; | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment