-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix(input): false
is no longer an empty value by default
#4153
Conversation
Thanks for the PR!
If you need to make changes to your pull request, you can update the commit with Thanks again for your help! |
`checkboxInputType` and `ngList` directives need to have special logic for whether they are empty or not. Previously this had been hard coded into their own directives or the `ngRequired` directive. This made it difficult to handle these special cases. This change factors out the question of whether an input is empty into a method `$isEmpty` on the `ngModelController`. The `ngRequired` directive now uses this method when testing for validity and directives, such as `checkbox` or `ngList` can override it to apply logic specific to their needs. Closes angular#3490, angular#3658, angular#2594
Nice patch! |
+1, very nice |
Wouldn't it be possible to provide an API for this that doesn't require monkey-patching? This functionality is needed, but I'm not keen on the API you created. |
@IgorMinar - can you give some more detail? There is no monkey patching going on here. Instead, I am creating an interface that allows This is done through the polymorphic method |
OK, so I guess, strictly, it is monkey patching individual instances of |
@petebacondarwin the |
Ignore my previous comment, I just realized that ng-required needs to read it. |
@petebacondarwin how about this vojtajina@c44fcb6 (it's one commit on the top of your PR) |
Made some little tweaks and merged as b56b21a. |
@vojtajina - Great! Thanks. |
This builds upon and improves @lgalfaso's PR #3658, without resorting to hard-coding fixes across directives.
checkboxInputType
andngList
directives need to have special logic for whetherthey are empty or not. Previously this had been hard coded into their
own directives or the
ngRequired
directive. This made it difficult to handlethese special cases.
This change factors out the question of whether an input is empty into a method
$isEmpty
on thengModelController
. ThengRequired
directive now uses thismethod when testing for validity and directives, such as
checkbox
orngList
can override it to apply logic specific to their needs.
Closes #3490, #3658, #2594