gpt4 book ai didi

模板语句中的 Angular 异步参数

转载 作者:行者123 更新时间:2023-12-01 22:02:15 24 4
gpt4 key购买 nike

我目前很难弄清楚如何在进行事件绑定(bind)时在模板语句中使用异步参数。

我尝试了以下代码段:

<div (click)="goToProfile((user|async)?.id)"></div>

它失败了

ng: Parser Error: Cannot have a pipe in an action expression at column 20 in [goToProfile((user|async)?.id)] in @2:19 ng: The pipe '' could not be found

最佳答案

你可以这样做

<div *ngIf="user | async as u" (click)="goToProfile(u.id)"></div>

关于模板语句中的 Angular 异步参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53289527/

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