Trying to user *ngIf and *ngFor in Modal but it does not work!!
in the console I get :
Can’t bind to ‘ngForOf’ since it isn’t a known property of ‘ion-list’.
Here is my module.ts of modal (add-food) :
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { IonicModule } from '@ionic/angular';
import { AddFoodPageRoutingModule } from './add-food-routing.module';
import { AddFoodPage } from './add-food.page';
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
AddFoodPageRoutingModule
],
declarations: [AddFoodPage]
})
export class AddFoodPageModule {}
and this is my code in HTML :
<ion-list padding *ngFor="let item of items">
<ion-item (click)="viewItem(item)">
{{item.title}}
<p>{{item.description}}</p>
</ion-item>
</ion-list>
item array :
public items = [
{ title: 'test 1', description: 'test 1' },
{ title: 'test 2', description: 'test 2' },
{ title: 'test 3', description: 'test 3' }
];
my app.module.ts :
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouteReuseStrategy } from '@angular/router';
import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
@NgModule({
declarations: [AppComponent],
entryComponents: [],
imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule],
providers: [
StatusBar,
SplashScreen,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
],
bootstrap: [AppComponent]
})
export class AppModule {}
1 post - 1 participant