问题
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 ) {}
}
回答1:
Just like @Pace commented, you can take a look at Ionic2 docs to see how to create a Modal.
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'));
}
}
来源:https://stackoverflow.com/questions/38540856/cant-resolve-all-parameters-for-modal