When I console log selectedVendor
in the method vendorUpdate
it shows the previous value of selectedVendor
instead of the new value.
<div>
<md-select id="vendorVariable" class="vm-select-wrap"
(ngModelChange)="vendorUpdate()"
[(ngModel)]="selectedVendor" placeholder="AWS"
name="vendorVariable">
<md-option *ngFor="let vendor of vendors" value={{vendor.small}}>
{{vendor.caps}}
</md-option>
</md-select>
</div>
TS file:
vendors: any = [
{caps: "AWS", small: "aws"},
{caps: "AZURE", small: "azure"}
];
selectedVendor :any;
vendorUpdate(){
this.selectedVendor = this.selectedVendor;
console.log(this.selectedVendor);
}
On selecting the value from select dropdown selectVendor prints the previous selected value, whereas the current selected value should be printed.