1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > Angular2 Use styles in Component

Angular2 Use styles in Component

时间:2019-10-15 02:19:47

相关推荐

Angular2 Use styles in Component

1 内联样式

/*** Created by Administrator on /7/23.*/import {Component, View, NgIf} from 'angular2/angular2';@Component({selector: 'ng-test',properties: ['showElement']})@View({styles:['div.normal-text{width: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 /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;}}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。