This repository has been archived by the owner on Sep 5, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(autocomplete): adds watcher for ngDisabled rather than 2-way binding
Closes #2160
- Loading branch information
973a2fc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of this change ?
And why
$parent
? And why notattrs.$observe
?I am a curious person, I know :)
973a2fc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if it's a bug in Angular or due to the complexity of this component, but using
$observe
caused it to be evaluated in the wrong scope.973a2fc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, obviously :) (it has an isolate scope).
But what was wrong with the previous implementation (2-way data-binding) as long as you don't try to "write back".
973a2fc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
973a2fc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should not watch
ngDisabled
directly.ng-disabled
setsdisabled
for you (eitherdisabled="disabled"
=> true ; or nothing => false). It is intended for the users not for the directive implementation. The user can useng-disabled
(<fooBar ng-disabled="ctrl.myBooleanVariable">
) or directlydisabled
(<fooBar disabled>
).A better way (taken from https://github.com/tkrotoff/ui-select/blob/master/src/select.js#L220) is to simply watch
disabled
attribute:See also my remarks on #2619: ng-checked, ng-disabled, ng-src... they all work the same way.
973a2fc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tkrotoff - we do watch
disabled
in the Select component.@robertmesserle - should we change autocomplete to match that approach?