- Notifications
You must be signed in to change notification settings - Fork27.4k
fix(form): make ngForm $pristine after nested control.$setPristine() (counter version)#13773
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
When calling $setPristine on the nested form or control,form becomes $pristine of all the nested controls are pristineClosesangular#13715
test/ng/directive/formSpec.js Outdated
@@ -714,7 +714,8 @@ describe('form', function() { | |||
expect(form.$error.maxlength[0].$name).toBe('childform'); | |||
inputController.$setPristine(); | |||
expect(form.$dirty).toBe(true); | |||
// this assertion prevents to propagate prestine to the parent form | |||
// expect(form.$dirty).toBe(true); |
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 change this toexpect(form.$dirty).toBe(false);
and remove the subsequent call toform.$setPristine()
.
It generally LGTM (with a couple of nitpicks), BUT: We need to properly handle added/removed controls. |
70049ae
tob77e14b
CompareNow it uses internal counter. It's a bit complicated, because we have to divide |
I think it's best to have the two alternative approaches as two independent PRs (so we can review/update/decide upon separately). Thx@linoleum-js for working on this, btw 👍 |
Has this been split? |
When calling $setPristine on the nested form or control,
form becomes $pristine of all the nested controls are pristine
Closes#13715