显示或不显示。
16lz
2021-01-22
Just a quick question about Angular (I'm not familiar with this framework yet and didn't find a success answer).
只是一个关于角度的简单问题(我还不熟悉这个框架,也没有找到一个成功的答案)。
I want to display or not a
我想展示一下。
example sentence
例句
according to the result of a ngIf.<div *ngFor="let tip of tips;let i=index;" class="alert {{getBackground(tip)}}" role="alert">
<h4 class="alert-heading">{{tip.title}} <span class="alert-date">{{getDate(tip.date)}}</span></h4>
<p>{{tip.details}}</p>
<p ng-if="{{getBackground(tip)}}==alert-danger">Example</p>
The {{getBackground(tip)}} expression give me a String, which I'm trying to test.
{{getBackground(tip)}表达式给我一个字符串,我正在尝试测试它。
Is that the correct way ?
这是正确的方法吗?
Thanks a lot !
谢谢!
Matthieu
马修
2 个解决方案
#1
1
You need to use *ngIf
not ng-if
here, And compare without {{....}}
您需要使用*ngIf而不是ng——如果在这里,并且不使用{{}}
<p *ngIf="getBackground(tip) == 'alert-danger'">Example</p>
更多相关文章
- 正则表达式以任何顺序匹配多个模式
- Javascript正则表达式应该允许空和非空字符串,但它不会
- JavaScript正则表达式定义字符集
- Python的运算符与表达式
- python正则表达式
- Python 正则表达式(5)电话号匹配
- 如何在python中使用命名组和datadict从正则表达式模式中组合字符
- Python正则表达式在分隔符之间查找特殊字符
- yield表达式, 四种形式