我在typescript中有这个组件定义:
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 { }
Run Code Online (Sandbox Code Playgroud)
根据这篇文章: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"(最新测试版AFAIK)