-
Notifications
You must be signed in to change notification settings - Fork 27.5k
feat(ngModelOptions): add validateOn option #7414
Conversation
Thanks for the PR! Please check the items below to help us merge this faster. See the contributing docs for more information.
If you need to make changes to your pull request, you can update the commit with Thanks again for your help! |
You can't render anything if you are not triggering a digest. So in this case, the system would know that the field is invalid but it couldn't do anything about it. This is why I think this PR is flawed. |
@IgorMinar - I must be completely missing what you meant to say. A digest always occurs after validation in the current implementation. Here is a working example of my current implementation: http://plnkr.co/edit/iQzU78XgWP42cfGnGAtq?p=preview As you can see, this behaves as I intended - the validation errors are displayed, but the model is not updated. Here is how it works without |
@shahata I see what you mean. ignore my comment :-) let me take a better look |
Add option to set different triggers for validation than the triggers that actually update the model. A new method `$$validateViewValue` was extracted from `$commitViewValue` which can be called when a `validateOn` trigger occurs. This method sets the control as dirty and runs all `$parsers`, but doesn't actually change the model. The idea is that many times people want to pend or debounce the updates to the model in order to prevent a lot of invocations of watchers or just simply to update their model only when a form is submitted, but they would still like their users to get feedback immediately when the view is dirty or invalid. BREAKING CHANGE: This commit introduces the option to run `$parsers` without setting the `$modelValue` with the result. Closes #7016
This is not a high priority feature so we are going to pop it in the icebox for a bit and revisit it if people start to show an interest. |
02dc2aa
to
fd2d6c0
Compare
cad9560
to
f294244
Compare
e8dc429
to
e83fab9
Compare
4dd5a20
to
998c61c
Compare
+1 |
Add option to set different triggers for validation than the triggers that actually update the model. A new method
$$validateViewValue
was extracted from$commitViewValue
which can be called when avalidateOn
trigger occurs. This method sets the control as dirty and runs all$parsers
, but doesn't actually change the model. The idea is that many times people want to pend or debounce the updates to the model in order to prevent a lot of invocations of watchers or just simply to update their model only when a form is submitted, but they would still like their users to get feedback immediately when the view is dirty or invalid.BREAKING CHANGE:
This commit introduces the option to run
$parsers
without setting the$modelValue
with the result.Closes #7016