Hello guys, please i need someone to help me, i am new to ionic and i am using ionic 3.7.0. I am writitng a program that accept data from an API it working perfectly. now i have added a button such that when ever you click on it you will be taken to new screen. i created a method and use with push(). now the pronblem is that it is showing this error:
Runtime Error cannot read property data of undefined.
Please can any put me through thanks.
on my .ts file
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import {RecipeProvider} from '../../providers/recipe/recipe';
import {detailsPage} from '../details/details';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
recipeList=[]
constructor(public navCtrl: NavController, private recipeService:RecipeProvider) {
this.getRecipeFromProvider();
}
getRecipeFromProvider(){
this.recipeService.getRecipes().subscribe((data)=>{
this.recipeList=data.results;
});
}
viewItem(item){
this.navCtrl.push(detailsPage);
}
}
.html file
<ion-header>
<ion-navbar>
<ion-title>
Welcome to Super Recipe
</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<ion-list>
<ion-item *ngFor = "let recipe of recipeList">
<ion-thumbnail item-start>
<img [src]="recipe.thumbnail">
</ion-thumbnail>
<h2>{{recipe.title}}</h2>
<p>Ingredients:{{recipe.ingredients}}</p>
<button ion-button clear item-right color="twitter" (click) ="viewItem(item.data)">View</button>
</ion-item>
</ion-list>
</ion-content>