查看: 1|回复: 0

angular 中*ngIf 和*ngSwitch判断语句

[复制链接]

0

主题

0

回帖

0

积分

积极分子

金币
0
阅读权限
220
精华
0
威望
0
贡献
0
在线时间
0 小时
注册时间
2009-6-8
发表于 2019-5-20 15:31:00 | 显示全部楼层 |阅读模式
<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;
}

效果:

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

相关侵权、举报、投诉及建议等,请发 E-mail:qiongdian@foxmail.com

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部