首页 > 其他 > 详细

angular 中*ngIf 和*ngSwitch判断语句

时间:2019-05-20 16:07:54      阅读:1264      评论:0      收藏:0      [点我收藏+]
<div style="text-align:center">
  <h1>
    Welcome to {{ title }}!
  </h1>
  <p *ngIf="true">show</p>
  <p *ngIf="isShow">hide</p>
  <p template="ngIf true">这是 ngIF 判断是否显示</p>

  <ul [ngSwitch]="status">
    <li *ngSwitchCase="1">已支付</li>
    <li *ngSwitchCase="2">订单已经确认</li> 
    <li *ngSwitchCase="3">已发货</li>
    <li *ngSwitchDefault>无效</li>
    </ul>
</div>
import { Component } from ‘@angular/core‘;

@Component({
  selector: ‘app-root‘,
  templateUrl: ‘./app.component.html‘,
  styleUrls: [‘./app.component.scss‘]
})
export class AppComponent {
  title = ‘angulardemo‘;
  status=‘2‘;
  isShow=false;
}

效果:

技术分享图片

angular 中*ngIf 和*ngSwitch判断语句

原文:https://www.cnblogs.com/loaderman/p/10894423.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!