I want to access form controls and disable some controls conditionally. In the following code, the form has no controls:
Component
export class OfferDialogComponent implements OnInit, AfterViewInit {
freemium = false;
@ViewChild('editForm') editForm: NgForm;
ngAfterViewInit(): void {
this.editForm.form.get("trialPeriod").disable();
}
}
Template
<form name="editForm" role="form" novalidate (ngSubmit)="save()" #editForm="ngForm">
How can I access and initialize form controls conditionally?