从 Angular 7 升级到 Angular 8 后,我的管道停止工作并出现错误:
TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))
10 | export class APipe implements PipeTransform {
11 |
> 12 | constructor(
| ^
13 | private readonly bPipe: BPipe,
14 | private readonly cPipe: CPipe) {}
或有类似错误:
Error: Found non-callable @@iterator
我的管道代码:
@Pipe({
name: 'aPipe'
})
export class APipe implements PipeTransform {
constructor(
private readonly bPipe: BPipe,
private readonly cPipe: CPipe) {}
transform(someValue: any, args?: any): any {
if (!someValue) {
return ' — ';
}
if (cond1) {
return this.bPipe.transform(someValue, ...args);
}
else {
return this.cPipe.transform(someValue, ...args);
}
return ' — ';
}
}
我是否必须@Injectable()
在 Angular8 中明确标记管道,或者有什么问题?