簡體   English   中英

*ngFor 在 Ionic Popover/Modal 中不起作用

[英]*ngFor in Ionic Popover/Modal not working

除了 Popover 和 Modal 之外,此代碼適用於我頁面中的任何位置。 我無法綁定到“ngForOf”,因為它不是“div”的已知屬性

有什么解決方法嗎?

<div *ngFor="let u of users">
  <ion-row>
    <ion-col size="12">
      <ion-label>
        <ion-title>{{ u.first}}</ion-title>
      </ion-label>
    </ion-col>
  </ion-row>
</div>
users: any[] = [
  {
    id: 1,
    first: 'Alice',
    last: 'Smith',
  },
  {
    id: 2,
    first: 'Bob',
    last: 'Davis',
  },
  {
    id: 3,
    first: 'Charlie',
    last: 'Rosenburg',
  }
];

我在這個鏈接中找到了答案,你應該在根應用模塊中添加模態組件:首先在你的 app.module 中導入模態頁面,

import {ModalPage} from "./home/modal.page"

然后在聲明和 entryComponents 中聲明它

declarations: [AppComponent,ModalPage],

entryComponents: [ModalPage],

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM