首页 > 解决方案 > Can I call a Pipe from a Pipe in Angular using Typescript?

问题描述

I'm new to this Angular and Typescript world. I´m currently struggling with the following pipe code: There is already a pipe that checks if object.struktur.id should be enabled or not. Now I have to do it with a loop. I literally just copied the code from the other pipe and changed the value to 'i' so that it can iterate.
and I don't know why this is not working.. that's why Im wondering if i can directly call the other pipe from this pipe and give the object[i].struktur.id as parameter. is this possible?

transform(group: any[]): boolean {
      let probe;
      for(let i=0; i<group.length;i++){
     combineLatest([
        this.iqsService.darfBogenBearbeiten$,
        this.iqsService.enabledStateInbearbeitung$.pipe(
           map(enabledState => enabledState[group[i].struktur.id] != null ? enabledState[group[i].struktur.id] : true),
           distinctUntilChanged()
        ),
        this._erhebungsService.istArchivierteErhebung$
     ]).pipe(
        map(([darfBearbeiten, strukturEnabled, istArchivierteErhebung]) => {
           if (!darfBearbeiten || istArchivierteErhebung) {
              probe= false;
           }
           probe= strukturEnabled;
        })
     );
      }

     return probe;
  }

标签: angulartypescriptpipe

解决方案


是的,您可以在其他管道中调用管道,只需启动管道并在其上调用转换

let pipe = new YourPipeClass();
let newValue = pipe.transform(value, args);

推荐阅读