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]ng-class and Encapsulated Component Style2的更多相关文章

  1. Angular CLI ng常用指令整理

    一.组件创建 ng generate component heroes 二.运行项目 ng serve --open //--open 立即打开 三.创建指令 ng g directive my-ne ...

  2. [Angular 2] ng-class and Encapsulated Component Styles

    import {Input, Component, View, NgClass} from "angular2/angular2"; @Component({ selector: ...

  3. Angular: 执行ng lint后如何快速修改错误

    当我第一次被分配到“修正执行ng lint语句后的错误”这项任务前,我就被导师提前告知这是一个很无聊的任务,当我开始后,我发现其实有一些办法可以加快这个无聊单调的工作.接下来,我就分享一下我的经验. ...

  4. 从flask视角理解angular(二)Blueprint VS Component

    Component类似flask app下面的每个blueprint. import 'rxjs/add/operator/switchMap'; import { Component, OnInit ...

  5. [Angular 2] Generate and Render Angular 2 Template Elements in a Component

    Angular 2 Components have templates, but you can also create templates inside of your templates usin ...

  6. [Angular 2] Building a Toggle Button Component

    This lesson shows you how to build a Toggle Button in Angular 2 from scratch. It covers using transc ...

  7. ANGULAR 使用 ng build --prod 编译报内存错误的解决办法

    如果你遇到如下的情况 <--- Last few GCs ---> [13724:0000020D39C660D0] 231298 ms: Mark-sweep 1356.3 (1433. ...

  8. [Angular & Unit Testing] Testing a RouterOutlet component

    The way to test router componet needs a little bit setup, first we need to create a "router-stu ...

  9. [Angular Unit Testing] Debug unit testing -- component rendering

    If sometime you want to log out the comonent html to see whether the html render correctly, you can ...

随机推荐

  1. Repeater的ItemDataBound 事件中e.Item.DataItem 的数据类型

    1.使用DataSet和DataTable绑定数据源时 DataRowView view = (DataRowView)e.Item.DataItem; 2.DataReader绑定数据源时 Syst ...

  2. java rmi 小记

    最近在搞Quartz任务监控管理,碰到了jmx,后来发现Quartz对jmx的支持不是很好,介绍的文档也比较少,另外Quartz可以很方便的支持rmi于是就看了一下rmi.下面把写的一些测试小例子附上 ...

  3. Struts2的创建Web项目入门

    之前学过javaEE开发,学了之后便去做前端了,再也没碰过javaEE.现在重新学习和部署,入门级,使用MyEclipse10版本. 简单说一下过程. struts步骤: 1. web project ...

  4. datagrid公用字段扩展

    easyui 1.3.5扩展 datagrid 控件 扩展公用段 把 (9082行) var opts = $.data(_698,"datagrid").options; 改成 ...

  5. 【原创】用shell+ant构建apk

    #!/bin/bash ######################################################################### ## $PRODVERSIO ...

  6. ubuntu 14.0 下github 配置

    一:创建Repositories 1:首先在github下创建一个帐号.这个不用多说,然后创建一个Repositories. 2:然后在ubuntu下安装git相关的东东: 1 sudo apt-ge ...

  7. BufferedOutputStream

    package file; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStr ...

  8. 【学习笔记】【oc】类的包装类 协议 category

    1.类的两种包装类: 将基本数据包装成对象:NSValue:NSNumber; NSValue是NSNumber的父类, NSValue用来封装一些基本数据, NSValue是一个通用的包装类,用来包 ...

  9. hibernate3 无法查询中文问题

    在查询中文时  hql语句在生成的语句中把中文显示为乱码 则在hibernate配置文件中加入: <property name="hibernate.query.factory_cla ...

  10. DbUtility-第一次接触

    DbUtility这个以前就知道,可是由于底层是4.5的框架,我就一直没有仔细看过,最近自己的开发框架升级到了4.5,就开始学习这个组件. 总体来说,这个组件用起来非常简单.举例说明: await d ...