feat(ngModel): provide ng-empty and ng-not-empty CSS classes#12848
feat(ngModel): provide ng-empty and ng-not-empty CSS classes#12848petebacondarwin merged 2 commits intoangular:masterfrom
Conversation
f529a4b to
2b046f9
Compare
|
I wonder if people will ask for this to be propagated to a parent |
|
I was trying not to mention that :-P |
|
For the original use case, you would then use |
src/ng/directive/ngModel.js
Outdated
There was a problem hiding this comment.
It doesn't really matter because we have control over when it is called but I agree it is probably better for consistency.
There was a problem hiding this comment.
This could be simplified by always using ctrl.$viewValue instead of passing it as an arg. It should only be the viewValue anyway. You'll have to change the order on line https://github.com/angular/angular.js/pull/12848/files#diff-ae1963e24d6328c3aa019c0c1b9f4432R851 though, because otherwise it'll use the old viewValue
There was a problem hiding this comment.
Actually it would have to use $$lastCommittedViewValue and we would have to change the order as you suggest. I am not that keen on doing this though as I don't feel that not passing in an argument makes it that much simpler.
|
Regarding my question
because only ng-empty doesn't work if I understood the issue correctly. |
|
@Narretz: Yes, you would use a combination of the CSS classes for the original use case, but this seemed reasonable and intuitive to me. |
|
Thanks for the review @Narretz. |
|
Yep, feel free to merge!
|
It is no longer appropriate to test this here as $animate takes care of queueing up CSS class changes into a single update.
If the `$viewValue` is empty then the `ng-empty` CSS class is applied to the input. Conversely, if it is not empty the `ng-not-empty` CSS class is applied. Emptiness is ascertained by calling `NgModelController.$isEmpty()` Closes angular#10050 Closes angular#12848
9d6087d to
630280c
Compare
I believe that this feature should be enough to fix #10050