1
<select [(ngModel)]="country" (change)="stateList = getStateList(country)">
        <option *ngFor="let c of countryList" [value]="c.Country.CountryID"></option>
</select>

Here in (ngModelChange) I want to assign the value returned from getStateList() to a varible, but it just calls the function and the return value is not bound to the variable.

ADyson
  • 57,178
  • 14
  • 51
  • 63

1 Answers1

0

You can simply assign inside the getStateList function itself

<select [(ngModel)]="country" (change)="getStateList(country)">
        <option *ngFor="let c of countryList" [value]="c.Country.CountryID"></option>
</select>

inside the component

getStateList(country : any){
   this.stateList = (getData);

}
Sajeetharan
  • 216,225
  • 63
  • 350
  • 396