[Angular 2]ng-class and Encapsulated Component Style2
2024-08-26 14:20:31
Many Components require different styles based on a set of conditions. Angular 2 helps you style your Components by allows you to define Styles inline, then choosing which styles to use based on the current values in your Controller.
import {Component, Input} from 'angular2/core';
@Component({
selector: 'todo-item-renderer',
template: `
<style>
.completed{
text-decoration: line-through;
}
</style>
<div>
<span [ngClass]="todo.status"
[contentEditable]="todo.isEdit">{{todo.title}}</span>
<button (click)="todo.toggle()">Toggle</button>
<button (click)="todo.edit()">Edit</button>
</div>
`
}) export class TodoItemRenderer{
@Input() todo
}
最新文章
- React 还是 Vue: 你应该选择哪一个Web前端框架?
- Lab_6_SysOps_AutoScaling_Linux_v2.5
- Javascript之旅——第三站:几个需要注意的运算符
- stm32cube--通用定时器--输入捕获
- 使用ODP.NET一次执行多句SQL语句
- js 后台弹窗
- Nginx系列~概念与windows下环境搭建
- SQL SERVER数据库服务操作
- window.name 跨域
- php获取server端mac和clientmac的地址
- CF908G Original Order
- PM2 Quick Start
- ELK 架构之 Elasticsearch 和 Kibana 安装配置
- redist命令操作(二)--哈希Hash,列表List
- day6.python字典练习题
- Python数据分析实例操作
- 20165215 学习基础和c语言基础调查
- 8Q - 献给杭电五十周年校庆的礼物
- iptables命令(备忘)
- JS常用时间处理方法