gpt4 book ai didi

html - angular 2包括所有页面通用的css文件

转载 作者:太空狗 更新时间:2023-10-29 18:07:23 25 4
gpt4 key购买 nike

我知道在 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;
}
}

我想包含一些可以像普通 html 一样在我的整个应用程序中使用的通用 css。

是否有任何 Angular 特定的方式来做这件事或者这是正确的方式??

最佳答案

index.html:

<!DOCTYPE html>
<html ng-app="app" ng-controller="AppController">
<head>
<title>Title</title>
<link rel="stylesheet" href="styles/sheet.css"/>
</head>
...

关于html - angular 2包括所有页面通用的css文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38371681/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com