[Angular 2]ng-class and Encapsulated Component Style2
2016-03-21 17:26
543 查看
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 }
相关文章推荐
- [Angular 2] Passing data to components with @Input
- angularJS provider/factory/service初解析
- 实践中学习AngularJS表单
- 为克服HTML在构建应用上的不足而设计! AngularJS简介!零玖玖教育
- AngularJS UI Router(ui.router)嵌套视图(Nested Views)
- ionic & AngularJS 传递url类型的参数
- Angular报错
- [Angular 2] Adding a data model
- [Angular 2] Using ng-model for two-way binding
- [Angular 2] Using ng-for to repeat template elements
- AngularJS学习笔记之一: AngularJS入门
- AngularJS学习笔记之二:开发、调试和测试工具
- [Angular 2] Using the @Inject decorator
- AngularJS中的指令实践开发指南(二)
- AngularJS 中的指令实践开发指南(一)
- 浅析AngularJS中的指令
- angularjs控制器之间通信,事件通知服务
- AngularJS入门之动画
- angularjs学习3--模块module
- 实践中学习AngularJS中的表单