Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.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
Angularjs .订阅函数不作为输入参数传递_Angularjs_Typescript_Rxjs_Async.js - Fatal编程技术网

Angularjs .订阅函数不作为输入参数传递

Angularjs .订阅函数不作为输入参数传递,angularjs,typescript,rxjs,async.js,Angularjs,Typescript,Rxjs,Async.js,我有一个从组件中的服务获取数组的函数,我想通过@Input将这个新获取的数组传递给另一个组件。在服务调用中,数组可以完全填充,但是如果我将console.log记录到其他任何地方,它将成为空数组。请帮忙。 这是我的数组getter函数,它在组件1中的ngOnInIt和ngOnChanges上调用 getSignOffs(){ this.signoffsService .getSignOffs( Number(this.workpaperSetId),

我有一个从组件中的服务获取数组的函数,我想通过@Input将这个新获取的数组传递给另一个组件。在服务调用中,数组可以完全填充,但是如果我将console.log记录到其他任何地方,它将成为空数组。请帮忙。 这是我的数组getter函数,它在组件1中的ngOnInIt和ngOnChanges上调用

getSignOffs(){
    this.signoffsService
      .getSignOffs(
        Number(this.workpaperSetId),
        SignOffElementTypeNumber.WorkpaperSetUserAdjustments,
        this.workpaperId.toString()
      )
      .subscribe(
        sign => {
          //reset array
          let signoffsUsable = [];
          
          //here we are getting the array of signoff history from the collection to use for displaying the circles
          if (sign[0]) {
            const arrayOfSignOffs: SignOffSearchModel[] = sign[0].signOffs;
            for (let i = 0; i < arrayOfSignOffs.length; i++) {
              signoffsUsable.push(arrayOfSignOffs[i]);
            }
            this.signOffCollection = signoffsUsable;
          }
        },
        error => {
          this.notificationService.error(this.errorMessage);
          this.handleError(error);
        }
      );
  }
getSignOffs(){
这是我们的签名服务
.getSignOffs(
编号(此为workpaperSetId),
SignOffElementTypeNumber.WorkpaperSetUserAdjustments,
this.workpaperId.toString()文件
)
.订阅(
符号=>{
//复位阵列
设signOffsAvailable=[];
//这里我们从集合中获取用于显示圆圈的签核历史数组
if(符号[0]){
const arrayOfSignOffs:SignOffSearchModel[]=sign[0]。signOffs;
for(设i=0;i{
this.notificationService.error(this.errorMessage);
此.handleError(错误);
}
);
}
其中this.signOffCollection是要通过传递给component2的数组id

<app-signoff
        class="d-flex align-items-center mt-1 mb-3"
        [signOffCollection]="signOffCollection"
      ></app-signoff>

同样,服务调用中的console.log会得到正确的数组,但在其他任何地方都会得到它的[]