* ngFor在模式(角度离子)中不起作用 [英] *ngFor doesn't work in modal (Angular ionic)
问题描述
Im在离子应用中使用角度,但在模态中ngForm不起作用.我认为这很简单,只需简单的代码即可.
Im using angular in ionic application but in a modal the ngForm doesnt works. I think its cleary whit a simple code.
<li *ngFor="let item of [1,2,3,4,5]; let i = index">
{{i}} {{item}}
</li>
此代码在页面的所有其余部分都显示了此内容->
this code show this in all rest of page ->
但是在这样的模式创建中
but in a modal create like this
async presentModal(test){
const modal = await this.modalController.create({
component: TestPage,
componentProps: {
test
}
});
modal.onWillDismiss().then(dataReturned => {
});
return await modal.present();
}
不显示任何内容.有什么建议为什么在模态* ngFor o中甚至* ngForm不起作用?我缺少什么?谢谢.
dont show anything. Any suggest why in the modal the *ngFor o even the *ngForm doesnt work? Something im missing? Thanks.
PD:我可以在模态中做我想做的每件事,并且像写"hello"或模态正确显示的东西一样工作,但是ngform不显示任何东西.
PD: I can do every thing i want in the modal and works like write "hello" or something the modal show correctly but the ngform dont show anything.
PD2:
我也尝试用mu模块.ts导入搜索以解决此问题...
Also mu module.ts with all i try to import searching something to fix this...
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]
})
推荐答案
将组件添加到您的app.module
Add the component to your app.module
import { ModalComponent } from './modal/modal.component';
@NgModule({
declarations: [ModalComponent],
entryComponents: [ModalComponent],
}),
providers: [
],
bootstrap: [AppComponent]
})
查看下面的链接以获取示例
check the link below for an example
https://stackblitz.com/edit/ionic-v4-angular-modal-vxttcw?file=src%2Fapp%2Fapp.module.ts
这篇关于* ngFor在模式(角度离子)中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!