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>

更多相关文章

  1. 正则表达式以任何顺序匹配多个模式
  2. Javascript正则表达式应该允许空和非空字符串,但它不会
  3. JavaScript正则表达式定义字符集
  4. Python的运算符与表达式
  5. python正则表达式
  6. Python 正则表达式(5)电话号匹配
  7. 如何在python中使用命名组和datadict从正则表达式模式中组合字符
  8. Python正则表达式在分隔符之间查找特殊字符
  9. yield表达式, 四种形式

随机推荐

  1. Android 通信录中的联系人操作
  2. Android SDK Tools R15 发布
  3. android 复制、粘贴文字
  4. android 新手学习笔记 点击事件
  5. Spinner下拉位置处理
  6. JAVA设计模式之Template method
  7. 教你如何用最新的技术快速开发一个完整的
  8. 【Android】性能分析工具:开篇
  9. Android 开发小经验
  10. recommend a book for android newcomer