angular 中*ngIf 和*ngSwitch判断语句
2024-09-01 09:42:45
<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;
}
效果:
最新文章
- 2.Powershell Console
- vim下打造python编辑器
- WebBrowser处理AJAX生成的网页内容!
- B站运维团队成长的血泪史
- Sqoop增量从MySQL中向hive导入数据
- 用 React 编写SVG图表
- WinForm使用webbrowser爬取数据,中文乱码问题
- JZ2440开发笔记(1)——arm-linux-gcc环境搭建
- hdu 2955 Robberies 背包DP
- Android 原生listview item伸展收缩效果 (续)
- Python魔法方法总结及注意事项
- OI回忆录——一个过气OIer的智障历程
- Python开发【第三篇】基本数据类型
- Thread类相关方法
- python面试题(一)
- Ubuntu18.04和OpenWrt 18.06.0 下使用aria2和BaiduExport处理百度盘下载
- O_NONBLOCK与O_NDELAY有何不同?
- PowerShell----Automatic_Variables(预定义变量)
- Raw-OS源代码分析之idle任务
- php-fpm 操作命令