[英]Angular 9 - The pipe 'keyvalue' could not be found
The pipe 'keyvalue' could not be found.找不到管道“keyvalue”。 in angular 9
在角 9
"@angular/animations": "^9.0.1",
"@angular/common": "~9.0.1",
"@angular/core": "~9.0.1",
"@angular/forms": "~9.0.1",
"@angular/platform-browser": "~9.0.1",
"@angular/platform-browser-dynamic": "~9.0.1",
"@angular/router": "~9.0.1",
<div *ngFor="let item of faqData | keyvalue; let i=index">
{{item.key}}:{{item.value}}
</div>
<p>Map</p>
<div *ngFor="let item of map | keyvalue">
{{item.key}}:{{item.value}}
</div>
faqData = { id: 1, name: "Abdul Rafay" };
object: {[key: number]: string} = {2: 'foo', 1: 'bar'};
map = new Map([[2, 'foo'], [1, 'bar']]);
It works fine with Angular9
and it should work fine with all versions of app using angular 6+.它适用
fine with Angular9
,它应该适用于使用 angular 6+ 的所有版本的应用程序。
However if you also can try the alternate way.但是,如果您也可以尝试其他方式。
<div *ngFor="let prop of key">
<div>key: {{prop}}</div>
<div>value: {{faqData [prop]}}<div>
</div>
and then in TS然后在 TS
get key(){
return Object.keys(this.faqData );
}
FIX: OP found that he was missing CommonModule under the imports FIX:OP 发现他在导入下缺少 CommonModule
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.