【发布时间】:2020-09-22 20:33:52
【问题描述】:
我有一个创建的类,它在我的 model.ts 文件夹中返回一个函数,如下所示:
@Injectable({
providedIn: 'root'
})
export class Lookup {
val: object,
etc,
etc,
getLookupVal(field: string, id: number): string {
returns stuff..
}
}
这是我的自定义管道的样子:
import { Pipe, PipeTransform } from '@angular/core';
import { Lookup } from '../config/models';
@Pipe({
name: 'lookup'
})
export class LookupValuePipe implements PipeTransform {
constructor(private _lookupValues: Lookup) { }
transform(field: string, id: number): any {
return this._lookupValues.getLookupVal(field, id);
}
}
这是我使用它的一个例子:
<h3>{{'prodstands'| lookup: selectedTask.taskinfo.prodstandid}}</h3>
But for some reason this is the error I keep getting:
ERROR Error: Arguments array must have arguments.
at injectArgs (core.js:685)
at core.js:11183
at _callFactory (core.js:20296)
【问题讨论】:
-
transform(field: string, id: number): any { return this._lookupValues.getLookupVal(field, id); _lookupValues 是什么?
-
@RafaelAndrade 抱歉,我对你的问题感到困惑
-
我想我现在明白了。 1 秒
-
从您发布的代码中我可以看出一切正常。也许你在某个地方有一个循环依赖。看起来 Angular 很难注入你的依赖项