Reputation: 6911
I'm trying to create custom input directive which will override default behavior of checkbox input. I can't seem to find a solution that would prevent default checkbox input directive from executing.
I've tried to just decorate the input, with priority of custom directive set to 0.
<input type="checkbox" my-custom-directive="0" ng-model="MyList" />
I've also tried to use a template and replace different element type.
<div my-custom-directive="0" ng-model="MyList"></div>
// part of directive object
return {
restrict: 'A',
template: '<input type="checkbox" />',
replace: true,
terminal: true,
priority: 0, ...
}
Ultimately what I'm trying to do is to bind a check box input to an array, and create behavior such that if a certain value is member of the array, input will be checked, otherwise it will not be checked. Also, if user checks the input box, directive will add mentioned value into the array.
Upvotes: 1
Views: 603
Reputation: 6911
In the end I've solved it by using ngNonBindable directive. I really dislike this solution because in more complex scenarios I might still want to use binding on certain elements of the template. If someone else has a better idea, I'll accept that answer once it appears.
return {
restrict: 'A',
template: '<input type="checkbox" ng-non-bindable />',
replace: true,
terminal: true,
priority: 0, ...
}
Upvotes: 1