Whenever I run the command ng s --aot, I encounter this message: Object is possibly 'null'.
I've been trying various solutions all morning to resolve it, but without success. The issue seems to be related to objects like email.valid, dirty, etc. within the code snippet below:
<form class="form-inline md-form form-sm" [formGroup]="validatingForm" (submit)="update(emailInput.value)">
<input mdbInput mdbValidate type="email" class="form-control form-control-sm mr-3 w-75" placeholder="Enter user's email" aria-label="Search" formControlName="email" #emailInput required />
<button mdbBtn type="button" color="primary" mdbWavesEffect (click)="update(emailInput.value)">
<mdb-icon fas icon="search" aria-hidden="true"></mdb-icon>
</button>
<mdb-error *ngIf="email.invalid && (email.dirty || email.touched)" class="mt-2">Email invalid</mdb-error>
<mdb-success *ngIf="email.valid && (email.dirty || email.touched)" class="mt-2">Email valid</mdb-success>
</form>
The TypeScript code snippet associated with this is as follows:
export class UsersComponent implements OnInit {
validatingForm: FormGroup;
token: any;
userDetails: {};
hasUsers = false;
emailValue: string;
constructor(private crudService: CrudService) {}
ngOnInit() {
this.validatingForm = new FormGroup({
email: new FormControl("", Validators.email)
});
this.loginAsAdmin();
}
get email() {
return this.validatingForm.get("email");
}