【发布时间】:2020-12-03 09:38:42
【问题描述】:
我正在使用 ionic 5 构建一个移动应用程序,当我尝试调用其中包含 *ng-If 的 ion-modal 时,我会收到此错误
Can't bind to 'ngIf' since it isn't a known property of 'ion-header'.
modal是comment.page.ts中的一个comment section,这里是comment.page.html的代码
<ion-header class="ion-no-border" *ngIf="!isLoading">
<ion-toolbar>
<ion-title class="centerAM">{{no_comm | shortNumber}} comment{{no_comm>1?'s':''}}</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
....
这里是 comment.module.ts 的代码
import { NgModule } from '@angular/core';
import { IonicModule } from '@ionic/angular';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { NgxEmojModule } from 'ngx-emoj';
import { CommentPageRoutingModule } from './comment-routing.module';
import { CommentPage } from './comment.page';
import { PipesModule } from '../../pipes/pipes.module';
@NgModule({
imports: [
CommonModule,
NgxEmojModule,
PipesModule,
FormsModule,
IonicModule,
CommentPageRoutingModule
],
schemas: [],
declarations: [ CommentPage]
})
export class CommentPageModule {}
这里是从 home.page.ts 调用 modal 的函数
async CommentModal(i, id) {
const modal = await this.modalCtrl.create({
component: CommentPage,
componentProps:{id},
swipeToClose: true,
cssClass: 'comment-modal'
});
await modal.present();
return
}
如果我应该在 home.module.ts 或 app.module.ts 中添加comment.module.ts,当页面加载时,它会自动加载模态而不需要用户点击任何东西,我还删除了从路线页面,它没有工作,请问我做错了什么
【问题讨论】:
标签: javascript angular ionic-framework