• Angular2 Use styles in Component


    1 内联样式

    /**
     * Created by Administrator on 2015/7/23.
     */
    import {Component, View, NgIf} from 'angular2/angular2';
    
    @Component({
        selector: 'ng-test',
        properties: ['showElement']
    })
    
    @View({
        styles:['div.normal-text{100px;height:50px;border:1px solid gray;}'],
        template: `<div class="normal-text">ngff-test</div><div *ng-if="showElement">hide-element</div>`,
        directives: [NgIf]
    })
    
    export class NgTest {
        //showElement:boolean;
    
        constructor() {
            //this.showElement = true;
        }
    }
    

    2 外部文件 use styleUrls:['','','']

    /**
     * Created by Administrator on 2015/7/23.
     */
    import {Component, View, NgIf} from 'angular2/angular2';
    
    @Component({
        selector: 'ng-test',
        properties: ['showElement']
    })
    
    @View({
        styleUrls:['../../css/index.css'],
        template: `<div class="normal-text">ngff-test</div><div *ng-if="showElement">hide-element</div>`,
        directives: [NgIf]
    })
    
    export class NgTest {
        //showElement:boolean;
    
        constructor() {
            //this.showElement = true;
        }
    }
    

      

  • 相关阅读:
    Explain详解
    InnoDB缓存---InnoDB Buffer Pool
    多线程之---线程同步
    多线程之--等待与通知
    谈算法与数据结构的学习
    分布式系统理论
    算法与数据结构基础
    算法与数据结构基础
    算法与数据结构基础
    算法与数据结构基础
  • 原文地址:https://www.cnblogs.com/lihaozhou/p/4677138.html
Copyright © 2020-2023  润新知