I have an array of object called options.
this is my html code
<ion-item>
<ion-label>place</ion-label>
<ion-select [(ngModel)]="place" (click)="optionsFn(item);">
<ion-option value="item" *ngFor="let item of options">{{item.name}} {{item.price}}</ion-option>
</ion-select>
</ion-item>
{{salespriceOp}}
{{quantityOp}}
this is my .ts file code
product_option_value_idOp
priceOp
salespriceOp
quantityOp
skuOp
nameOp
options = [
{
"product_option_value_id": "45",
"name": "Bangalore Auto",
"quantity": "12",
"sku": "56876",
"price": "100.00",
"salesprice": "50"
},
{
"product_option_value_id": "51",
"name": "Hyderabad Auto",
"quantity": "23",
"sku": "56543",
"price": "200.00",
"salesprice": "60"
},
{
"product_option_value_id": "52",
"name": "Delhi Auto",
"quantity": "14",
"sku": "98767",
"price": "300.00",
"salesprice": "80"
}
];
constructor(public navCtrl: NavController) {
}
optionsFn(item) {//here item is an object
console.log(item);
this.product_option_value_idOp = item.product_option_value_id;
this.priceOp = item.price;
this.salespriceOp = item.salesprice;
this.quantityOp = item.quantity;
this.skuOp = item.sku;
this.nameOp = item.name;
}
i am able to invoke the function but i am getting undefined in
console.log(item)
optionsFn
function from select tag. you have to add it onion-option
tag – ranakrunal9ion-select
tag only if i use inion-options
tag i am not able to invoke the function itself – Mohan Gopi[value]=item
inion-option
and need to usegaming
in youroptionsFn
function. so remove argument fromoptionsFn
and try to check. – ranakrunal9nes
. You are binding the value of select to something calledgaming
but you don't seem to have that in your component class. Can you please post your full component class. – BradoptionsFn(item)
– Mohan Gopi