Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.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 离子3和角度2中的多个@输入_Angular_Typescript_Ionic Framework_Ionic3_Angular2 Custom Component - Fatal编程技术网

Angular 离子3和角度2中的多个@输入

Angular 离子3和角度2中的多个@输入,angular,typescript,ionic-framework,ionic3,angular2-custom-component,Angular,Typescript,Ionic Framework,Ionic3,Angular2 Custom Component,在我的Ionic 3项目中,我创建了自定义组件my component。 现在我们知道使用angular@Input可以将数据传递给这个组件。 我有两个输入作为 @Input('finder') myFinder: Finder; //Finder is an Interface @Input('list') myList: Array<any>; @Input('finder')myFinder:finder//Finder是一个接口 @输入('list')myList

在我的Ionic 3项目中,我创建了自定义组件my component。 现在我们知道使用angular@Input可以将数据传递给这个组件。 我有两个输入作为

  @Input('finder') myFinder: Finder; //Finder is an Interface
  @Input('list') myList: Array<any>; 
@Input('finder')myFinder:finder//Finder是一个接口
@输入('list')myList:数组;
我将此组件用作

<my-component [finder]="dataFinder" [list]="aList"></my-component>

dataFinder
aList
都有值,但是
myFinder
值总是
undefined
,其中
myList
被正确填充


这对使用多个输入是否有任何限制?

实际上,您根本不需要维护两个数据绑定属性。你可以做得更优雅,如下所示。希望代码是不言自明的

我的班级

.html



不,没有限制,请在plunker/stackblitz中重现此问题:)对不起,伙计们。这是我送的一封信。我正在读取构造函数中的输入参数。它应该在ngAfterViewInit()之后完成。好的,您也可以在OnInit中完成,在那里输入也可用。
export class MyClass{
   finder:Finder;
   myList:Array<any>;   
}
@Input('data') data: MyClass;
<my-component [data]="data"></my-component>