zoukankan      html  css  js  c++  java
  • [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
    }
  • 相关阅读:
    Java第二次作业
    JAVA学习计划
    学生选课系统
    抽奖
    Java第二次作业
    Java第六次作业修改版
    Java第六次作业
    JAVA第五次作业
    Java第四次作业
    JAVA第三次作业
  • 原文地址:https://www.cnblogs.com/Answer1215/p/5302829.html
Copyright © 2011-2022 走看看