我在打字稿中有这个组件定义:
import {Component, ViewEncapsulation} from 'angular2/core';
@Component({
selector: 'my-app',
templateUrl: '/views/sandbox.html',
styleUrls: ['/styles/sandbox.css'],
styles: [`.wow { background-color: red; }`],
encapsulation: ViewEncapsulation.Emulated
})
export class SandBox { }
根据这篇文章:http ://blog.thoughtram.io/angular/2015/06/25/styling-angular-2-components.html 样式部分和外部样式表中的样式都应该内联到标题中通过角度。
不幸的是,第二个没有被注入,角度只注入了样式部分中的一个。
我试过从浏览器访问/styles/sandbox.css,没问题。Angular 也能够访问 /views/sandbox.html 所以我不知道为什么它没有发生。
我正在使用:“angular2”:“2.0.0-beta.2”(最新的 beta AFAIK)