Angular - 找不到管道 'keyvalue'

标签 angular angular-pipe

我正在用简单的代码测试 Angular 的 keyvalue 管道:

import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  template: `<div *ngFor="let prop of testObj | keyvalue">
      <div>key: {{prop.key}}</div>
      <div>value: {{prop.value}}<div>
    </div> `
})
export class AppComponent {
  testObj = { id: 1, name: "Abdul Rafay" }
}

但它给了我这个错误:

Template parse errors: The pipe 'keyvalue' could not be found ("]prop of testObj | keyvalue"> key: {{prop.key}} value: {{prop.value}}"): ng:///AppModule/AppComponent.html@0:17 Evaluating src/main.ts Booting application

我错过了什么吗?这是我的 Stackblitz

最佳答案

您的代码没问题。您只需将依赖项更新到 6.1 即可使用 keyvalue 管道。

堆栈 Blitz here

关于Angular - 找不到管道 'keyvalue',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51916111/

相关文章:

angular - Angular 2 中的 $templateCache?

angular - 如果 Observable 使用异步管道,是否需要取消订阅?

Angular - 不纯管道与函数

angular - 添加路由后应用程序出错

加载图像时 Angular 4 空调用

Angular - 将管道作为变量传递

java - 对于未经授权的用户,重定向到用户友好的错误页面

angular - 从 void 函数返回

angular - @firebase/firestore : Firestore (5. 0.4) : Could not reach Cloud Firestore backend. 后端在 10 秒内没有响应

javascript - Angular 4 通用延迟加载错误