2016-07-23 54 views
0
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) {} 
} 

enter image description here无法解析模态的所有参数:

+0

你可以把modalcomponent代码在这里。问题在模块组件的构造函数中。 – micronyks

+0

它是一种离子型呼吸剂。这不是我的代码。 – rakete

+0

好吧。错误表示无法在启动模式时找到用于模态的依赖关系。 – micronyks

回答

2

就像@Pace评论,你可以在Ionic2 docs看一看,看看如何创建一个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')); 
} 

} 
相关问题