angular - *ngfor array to ion-list in ionic 2 -


i new in ionic 2. created array want loop array ion-list

my produk.ts

import { component } '@angular/core'; import { navcontroller, navparams } 'ionic-angular';   @component({   selector: 'page-produk',   templateurl: 'produk.html', }) export class produkpage {      constructor(public navctrl: navcontroller, public navparams: navparams) {     var menu: any[] = [       "menu 1",       "menu 2",       "menu 3"     ];   }  } 

i tried code in html, doesn't work

<ion-content padding>    <ion-list>     <ion-item *ngfor = "let item of menu;">      {{menu}}     </ion-item>     </ion-list>  </ion-content> 

menu needs class variable work.

export class produkpage {  menu:any[]=[]; //initialize empty list avoid undefined/null errors `menu` in template.   constructor(public navctrl: navcontroller, public navparams: navparams) {     this.menu = [       "menu 1",       "menu 2",       "menu 3"     ];   } } 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -