Hi Jonathan,
Looks good. Altough, it can be a bit simpler, have a look at this:
@Component({
selector: 'form-child',
template: `
<div>
<form #campaignForm="ngForm">
<input type="text" [ngModel]='data.input' name='input' required/>
</form>
</div>
`,
})
export class FormChild implements OnInit, AfterViewInit, AfterViewChange {
@Output() valid = new EventEmitter();
@ViewChild('campaignForm') campaignForm: NgForm;
constructor() {}
ngOnInit() {
this.campaignForm.valueChanges.subscribe(data => {
this.valid.emit(this.campaignForm.form.valid);
}
}
}
Will work just as well, and you can get rid of some extra constructs.
Regards
Sander
--
You received this message because you are subscribed to the Google Groups
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.