[Angular 2]ng-class and Encapsulated Component Style2
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的更多相关文章
- Angular CLI ng常用指令整理
一.组件创建 ng generate component heroes 二.运行项目 ng serve --open //--open 立即打开 三.创建指令 ng g directive my-ne ...
- [Angular 2] ng-class and Encapsulated Component Styles
import {Input, Component, View, NgClass} from "angular2/angular2"; @Component({ selector: ...
- Angular: 执行ng lint后如何快速修改错误
当我第一次被分配到“修正执行ng lint语句后的错误”这项任务前,我就被导师提前告知这是一个很无聊的任务,当我开始后,我发现其实有一些办法可以加快这个无聊单调的工作.接下来,我就分享一下我的经验. ...
- 从flask视角理解angular(二)Blueprint VS Component
Component类似flask app下面的每个blueprint. import 'rxjs/add/operator/switchMap'; import { Component, OnInit ...
- [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 ...
- [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 ...
- ANGULAR 使用 ng build --prod 编译报内存错误的解决办法
如果你遇到如下的情况 <--- Last few GCs ---> [13724:0000020D39C660D0] 231298 ms: Mark-sweep 1356.3 (1433. ...
- [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 ...
- [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 ...
随机推荐
- C#里巧用DateTime预设一些可选的日期范围(如本年度、本季度、本月等)
//大家在做报表或查询的时候都会有给用户预设一些可选的日期范围(如上图) //如本年度销售额.本季度利润.本月新增客户 //C#里内置的Da ...
- ORA-00214: controlfile '/u01/app/oracle/oradata/[sid]/control01.ctl' version inconsistent with file '/u01/app/oracle/oradata/[sid]/control03.ctl'
Sample error: SQL> startupORACLE instance started. Total System Global Area 285212672 bytesFixed ...
- Undefined symbols for architecture x86_64:
真机运行正常, 但要在模拟器运行的时候, 编译就报错了: 解决方法: 1.将Build Settings的Architectures修改为arm7 armv7s.Xcode7默认是加上arm64的,但 ...
- Java反射 - 2(对象复制,父类域,内省)
为什么要复制对象?假设有个类Car,包含name,color2个属性,那么将car1对象复制给car2对象,只需要car2.setName(car1.getName)与car2.setColor(ca ...
- 解决Access restriction问题
今天在导入一个包时报错了
- JS-商品图片点击轮换
//小图预览区域图片轮换键const LIWIDTH=62;var moveCount=0;document.getElementById("btForward").onclick ...
- Android Studio下运行UiAutomator
之前学习UiAutomator均是在eclipse下,因学习Android开发接触AS越来越频繁,于是想知道AS下如何建立UiAutomator项目.网上的资料多很凌乱,查了很多资料,实践后发现,只要 ...
- [SQL注入3]from_sqli_to_shell_II
[SQL注入1]这关学习盲注 ,这篇还有些东西没理透,后面搞明白了再修改. http://www.pentesterlab.com/exercises/from_sqli_to_shell_II/ 准 ...
- 解决TextView与RadioGroup不对齐的问题
TextView和RadioGroup是在同一个LinearLayout中的,控件摆放方式是android:orientation="horizontal",虽然三个控件是水平摆放 ...
- 使用AlertDialog创建对话框的大致步骤
1.创建AlertDialog.Builder对象,该对象是AlertDialog的创建器.2.调用AlertDialog.Builder的方法为对话框设置图标.标题.内容等.3.调用AlertDia ...