* ngIf指令的替代名称

时间:2016-10-03 14:38:38

标签: angular angular-directive angular-ng-if

很久以前,Angular 2的文档提到了*ngIf的替代名称,它没有使用星号。我相信它与<prefix>-ng-if类似,其中<prefix>是一些简短的前缀。

我在最新的文档中找不到对此的任何引用。

用例是我需要使用的xml解析器不支持以'*'开头的属性。

2 个答案:

答案 0 :(得分:2)

您可以使用

<template [ngIf]="expr"></template>

<template bind-ngIf="expr"></template>

答案 1 :(得分:1)

您可以template使用[ngIf](带属性绑定)

<template [ngIf]="condition">
  <p>
    Content Goes here
  </p>
</template>
相关问题