Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular Can';t解析模态的所有参数:(?,?,?)_Angular_Typescript_Ionic Framework_Ionic2_Ionic3 - Fatal编程技术网

Angular Can';t解析模态的所有参数:(?,?,?)

Angular Can';t解析模态的所有参数:(?,?,?),angular,typescript,ionic-framework,ionic2,ionic3,Angular,Typescript,Ionic Framework,Ionic2,Ionic3,就像@Pace评论的那样,您可以看看如何创建模式 您不必像现在这样将其包含在提供者数组或构造函数中。相反,您应该像下面这样使用Modal.create(…)方法: import { Component, Inject } from '@angular/core'; import { NavController, Modal } from 'ionic-angular'; import { PopupPage } from '../../components/modal/modal.page';

就像@Pace评论的那样,您可以看看如何创建
模式

您不必像现在这样将其包含在
提供者
数组或
构造函数中。相反,您应该像下面这样使用
Modal.create(…)
方法:

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 ) {}
}

你能把modalcomponent代码放在这里吗。问题出在modalcomponent的构造函数中。它是一个离子组件。这不是我的密码,好吧。错误表示在启动modal时找不到modal需要的依赖项。我很确定modal不是要注入的。查看下表,似乎模态总是要用
模态来构造。创建
。我相信Angular正在尽最大努力为您构建一个构造函数,但由于Modal没有无参数构造函数,并且没有标记为
@Injectable
,所以它几乎无能为力。您想解决什么问题?同样,Modal不应该是提供者,也不应该在提供者数组中。
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'));
 }

}