Get Item Name from ngFor

2019-08-09 02:46发布

I am selecting from following list:

<ion-select multiple="true" okText="Select" cancelText="Cancel" required 
[(ngModel)]="retailerItemModel" formControlName="retailerItem" 
name="retailerItem">
        <ion-option *ngFor="let item of itemList | async" 
[value]="item.itemPrice">
          {{item.itemName}} &nbsp;Rs.{{item.itemPrice}}
        </ion-option>            
      </ion-select>

I am calculating the totalValue with item.itemPrice as [value] (mentioned above) but I want to fetch the item.itemName too.. I am getting correct value of itemPrice but not getting itemName.. Pls suggest how to structure [value] to get the correct value for both itemName and itemPrice

enter image description here

Following is the TS file for getting the itemList:

public itemList: FirebaseListObservable<any>;
this.itemList = this.itemProvider.getItemList();

The itemProvider TS:

getItemList(): FirebaseListObservable<any>{
return this.afDatabase.list(`userProfile/${this.userId}/itemList/`);
}

Complete firebase output [![enter image description here][2]][2]

saveItem(itemName: string, itemQuantity: number, itemUnit: string, itemPrice: number): firebase.Promise<any>{
return this.afDatabase.list(`userProfile/${this.userId}/itemList/`).push({      
  itemName,
  itemQuantity,
  itemUnit,
  itemPrice
});

}

0条回答
登录 后发表回答