[英]angular 2 include css file common to all pages
我知道要包含內部樣式並在Angular 2中包含組件的外部樣式
import {Component} from 'angular2/core';
@Component({
selector: 'test',
templateUrl:'app/test.component.html',
styleUrls:['app/test.component.css']
})
export class AppComponent {
carparts = [
{
"id": 1,
"name": "Super Tires",
"description": "These tires are the very best",
"inStock": 5
},
{
"id": 2,
"name": "Reinforced Shocks",
"description": "Shocks made from kryptonite",
"inStock": 0
}];
totalCarParts(){
let sum = 0;
for (let carPart of this.carparts) {
sum += carPart.inStock;
}
return sum;
}
}
我想包括一些可以在我的整個應用程序中使用的常見CSS,如普通的html。
是否有任何角度特定的方式做到這一點或這是正確的方法?
index.html的:
<!DOCTYPE html>
<html ng-app="app" ng-controller="AppController">
<head>
<title>Title</title>
<link rel="stylesheet" href="styles/sheet.css"/>
</head>
...
或者,標准Angular項目文件集中有一個src / styles.css文件。 如果您將樣式添加到其中,它們將自動包含在index.html中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.