Hi Jonathan,
Just realised, you don't need a template var to get the form, this will
work also, and your template gets cleaner:
@Component({
selector: 'form-child',
template: `
<div>
<form>
<input type="text" [ngModel]='data.input' name='input' required/>
</form>
</div>
`,
})
export class FormChild implements OnInit, AfterViewInit, AfterViewChange {
@Input() data: any;
@Output() valid = new EventEmitter();
@ViewChild(NgForm) campaignForm: NgForm;
constructor() { }
ngOnInit() {
this.campaignForm.valueChanges.subscribe(data => {
this.valid.emit(this.campaignForm.form.valid);
}
}
}
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.