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 ) {}
}
答案 0 :(得分:3)
就像@Pace评论一样,您可以查看Ionic2 docs,了解如何创建 a Modal
。
您不必像往常一样将其包含在providers
数组或constructor
中。相反,您应该使用Modal.create(...)
方法,如下所示:
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'));
}
}