I have written code for my HTML
<select [(ngModel)]="empfile.storeno" class="form-control">
<option *ngFor="let p of concept" [ngValue]="p.MAP_Code">{{p.MAP_Code}}</option>
</select>
As for my component
public concept = [];
public datakartu: any = {cardno:""};
public empfile : any = {fullname:"",nik:"",disclimit:"",birthday:"",email:"",storeno:""};
constructor(
private _router: Router,
private _httpprovider: Httpprovider
) {}
ngOnInit() {
}
cardnof(newValue) {
this.datakartu.cardno = newValue
this._httpprovider.httpReq('http://192.168.1.40:5000/getdataemp','POST',{cardno:newValue},null).subscribe((data)=> {
var rData = [];
for (let i=0;i<data.length;i++) {
rData.push(data[i]);
}
var store = rData.map(i=>(i.Store_ID)).toString();
this.empfile.storeno = store; << this line updates the display of the combobox
console.log(this.empfile.storeno); << here the console log is displayed
});
}
I added this.empfile.storeno = store;
to change the combobox display based on database values, but it shows up blank.
However, when I use console.log()
, the value is there but it doesn't display on the screen.https://i.sstatic.net/HOorj.png
Basically, I want to fill in other fields with data from the database after entering the card number, but the combobox isn't displaying anything. The console log does show the value.
https://i.sstatic.net/Jipd0.png
Here is the result when I console log:
this.empfile.storeno = store;