I'm having trouble selecting the first option after the user enters their email, but it remains unselected. Any ideas on how to solve this?
HTML Code:
<label for="login"><b>User:</b></label>
<input type="email" id="login" name="login" ngModel class="form-control" placeholder="Email"
required autofocus (focusout)="onSelect()">
<label><b>Company:</b></label>
<select ngModel name="CompanyId" class="form-control" id="CompanyId" disabled="{{ disabled }}">
<option *ngFor="let company of companies; index as i" value="{{company.id}}"
>{{ company.name }}</option>
</select>
TypeScript Code:
onSelect() {
if ($("#login").val()== null || $("#login").val() =="") {
} else {
this.error = false;
this.alertService.clear();
let email = (document.getElementById("login") as HTMLInputElement).value;
localStorage.setItem(constants.emailSafeguard, email);
this.service.getCompanies(email).subscribe(list => {
this.companies = list;
if(list.length > 1) {
this.disabled = false;
} else {
this.disabled = true;
}
})
}
}