无法解析Modal的所有参数:(?,?,?) [英] Can't resolve all parameters for Modal: (?, ?, ?)

查看:209
本文介绍了无法解析Modal的所有参数:(?,?,?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

import { Component, Inject } from '@angular/core';
import { NavController, Modal } from 'ionic-angular';

import { PopupPage } from '../../components/modal/modal.page';

@Component({
  templateUrl: 'build/pages/spot/spot.html',
  providers: [ Modal ]
})
export class SpotComponent {

  constructor(@Inject(Modal) private modal: Modal ) {}
}

推荐答案

就像@Pace一样评论说,你可以看看 Ionic2 docs ,看看如何创建一个模态

Just like @Pace commented, you can take a look at Ionic2 docs to see how to create a Modal.

您不必将它包含在 providers 数组或构造函数中就像你在做的那样。相反,您应该使用 Modal.create(...)方法,如下所示:

You don't have to include it in the providers array or in your constructor like you're doing. Instead you should use the Modal.create(...) method like this:

import { Modal, NavController, NavParams } from 'ionic-angular';

@Component(...)
class HomePage {

 constructor(/* ..., */ private nav: NavController) {
   // Your code...
 }

 presentProfileModal() {
   // Create the modal using the layout from the Profile Component
   let profileModal = Modal.create(Profile, { paramId: 12345 });

   // Show the modal
   this.nav.present(profileModal);
 }

}

@Component(...)
class Profile {

 constructor(/* ..., */ private params: NavParams) {
   // Get the parameter by using NavParams
   console.log('paramId', params.get('paramId'));
 }

}

这篇关于无法解析Modal的所有参数:(?,?,?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆