*ngFor 不适用于模态(Angular ionic)

Pab*_*hez 4 ionic-framework ngfor angular

我在离子应用程序中使用角度,但在模态中 ngForm 不起作用。我认为只需简单的代码就可以清楚地了解。


    <li *ngFor="let item of [1,2,3,4,5]; let i = index">
        {{i}} {{item}}
      </li>
Run Code Online (Sandbox Code Playgroud)

此代码在页面的所有其余部分中显示了这一点 - >

列表

但在模态中创建像这样

 async presentModal(test){
    const modal = await this.modalController.create({
      component: TestPage,
      componentProps: {
          test
      }
    });
    modal.onWillDismiss().then(dataReturned => {

    });
    return await modal.present();
   }
Run Code Online (Sandbox Code Playgroud)

不要显示任何东西。有人建议为什么在模态中 *ngFor o 甚至 *ngForm 不起作用?我缺少什么吗?谢谢。

PD:我可以在模态中做我想做的所有事情,就像写“你好”或模态正确显示的内容,但 ngform 不显示任何内容。

PD2:

还有 mu module.ts 以及我尝试导入的所有内容,搜索一些内容来解决这个问题...

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';

import { IonicModule, NavController } from '@ionic/angular';

import { TestPageRoutingModule } from './test-routing.module';

import {ReactiveFormsModule} from '@angular/forms';
import { TestePage } from './test.page';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from 'src/app/app.component';


@NgModule({
  imports: [
    BrowserModule,
    IonicModule,
    CommonModule,
    FormsModule,
    TestPageRoutingModule,
    ReactiveFormsModule
  ],
  providers: [
    BrowserModule,
    IonicModule,
    CommonModule,
    ReactiveFormsModule,
    NavController
  ],
  declarations: [TestPage],
  bootstrap: [AppComponent]
})
Run Code Online (Sandbox Code Playgroud)

Nia*_*ore 8

将组件添加到您的 app.module

import { ModalComponent } from './modal/modal.component';


@NgModule({
  declarations: [ModalComponent],
  entryComponents: [ModalComponent],
  
  }),
  providers: [
  ],
  bootstrap: [AppComponent]
})
Run Code Online (Sandbox Code Playgroud)

检查下面的链接以获取示例

https://stackblitz.com/edit/ionic-v4-angular-modal-vxttcw?file=src%2Fapp%2Fapp.module.ts