gpt4 book ai didi

Angular - 找不到管道 'keyvalue'

转载 作者:太空狗 更新时间:2023-10-29 17:12:14 27 4
gpt4 key购买 nike

我正在用简单的代码测试 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com