angular - 如何在三元表达式的字符串内插入 *ngFor 变量?(角度)
问题描述
我试过的:
<mat-step *ngFor="let name of names" [label]="name" [completed]="name + 'IsCompleted'">
<button mat-button (click)="redirectToNameUrl(name)" mat-raised-button color="primary">
{{ (inProgress ? 'In progress...' : "'Sign in with ' + name + 'details!'" )}}
</button>
</mat-step>
注意:嵌套车把似乎也不起作用。
结果:
一个按钮,上面写着'Sign in with ' + name + 'details!'
我希望它会说:
Sign in with james details!
谢谢
解决方案
试试这样
<mat-step *ngFor="let name of names" [label]="name" [completed]="name + 'IsCompleted'">
<button mat-button (click)="redirectToNameUrl(name)" mat-raised-button color="primary">
{{ (inProgress ? 'In progress...' : 'Sign in with ' + name + 'details!' )}}
</button>
</mat-step>
您不需要文本周围的额外双引号
推荐阅读
- python - python - 如何使用Python按排序顺序显示字典中的字典?
- javascript - 访问模型类中的字段始终未定义
- rpa - 如何在 Automation Anywhere 变量中传递连字符 ( - ) 而不是运算符?
- jenkins - 如何在 Jenkins 声明式语法中添加 try catch 块。?
- sql - 使用 PostgreSQL 的 CTE 按时间戳过滤不起作用
- visual-studio-code - 如何在远程 VS Code 窗口中使用不同的主题
- kubernetes - 无法让我的有状态服务运行。Pod 无法调度到节点上
- bash - 用长度替换模式(Bash 的便携式解决方案)
- python - 检查状态是否为已付费并相应地显示内容
- swift - 使用标签栏呈现视图控制器