Han*_*Che 3 ionic-framework angular ionic4
根据Ionic 4文档,您可以通过componentProps属性传递数据.在Ionic3中,我可以使用navParams服务检索它.我如何在Ionic 4中做到这一点?
async presentModal() {
const modal = await this.modalController.create({
component: ModalPage,
componentProps: { value: 123 }
});
return await modal.present();
}
Run Code Online (Sandbox Code Playgroud)
Sur*_*iya 15
你需要使用@Input()装饰器.
async presentModal() {
const modal = await this.modalController.create({
component: ModalPage,
componentProps: { value: 123 }
});
return await modal.present();
}
Run Code Online (Sandbox Code Playgroud)
零件:
@Component({
selector: 'ModalPage',
templateUrl: './ModalPage.component.html',
styleUrls: [ './ModalPage.component.css' ]
})
export class ModalPage {
name = 'Angular';
@Input() value: any;
}
Run Code Online (Sandbox Code Playgroud)