Angular4 ngIf 基础问题

应该是我没弄明白,使用else块使用then和else块 有什么区别吗?
如下,不都是在 ts 里控制 condition 的值,即 true flase 吗?
并且使用 使用then和else块 也只能匹配两项内容?

使用else块
<div *ngIf="condition; else elseBlock">111</div>
<ng-template #elseBlock>222</ng-template>
使用then和else块
<div *ngIf="condition; then thenBlock else elseBlock">AAA</div>
<ng-template #thenBlock>BBB</ng-template>
<ng-template #elseBlock>CCC</ng-template>
阅读 3.6k
1 个回答

使用else块,那么条件为真的话,ngIf这块保留

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进