I have a form in Angular2 (for example)
<form id="myLovelyForm" name="myLovelyForm" #myLovelyForm="ngForm"> <label [attr.for]="myLovelyCheckbox"> <input [attr.id]="myLovelyCheckbox" type="checkbox" [(ngModel)]="myLovelyCheckbox"> <span class="myLovelyCheckbox">myLovelyCheckbox</span> </label> </form>
and the animation that should start if the form is dirty:
<div id="myLovelyNotification" class="myLovelyNotification" [@notification]="myLovelyForm.form.dirty"> ..... ..... </div>
The animation works correctly if I set [@notification] = true, but my myLovelyForm.dirty does not work if I touch the form and change the element.
If the @notification value is false, the animation stops, i.e. if the checkbox was selected earlier, and I cancel it by mistake and select it again, the form is not untouched (touched), but not dirty, so the animation should stop. If I manually set @notification = false, it works correctly.
The big question is: how can I correctly identify / view the "dirty status" of an angular2 form?
source share