在Angular中,可以使用styleUrls
属性来加载CSS文件,但如果想要加载标签而不是外部的CSS文件,可以使用
styles
属性来实现。
以下是一个示例:
import { Component } from '@angular/core';
@Component({
selector: 'app-example',
template: `
Hello, Angular!
`,
styleUrls: []
})
export class ExampleComponent { }
在上述示例中,我们在template
属性中添加了一个标签,并在其中定义了一些CSS规则。注意,
styleUrls
属性被设置为空数组,这样将不会加载任何外部CSS文件。
通过这种方式,Angular将加载标签中定义的CSS样式。