2017-02-19 38 views
0

我使用的是Angular 2.4,我在我的index.html文件中链接了一些CSS文件,但它们是我不希望它们设计的样式区域,因此我决定将它们与styleUrls,以便它们只适用于该特定组件。做完这些之后,我的风格不再适用于任何地方。我试图用styleUrls以几种不同的方式将它们链接起来,但无法使其正常工作。styleUrls无法在Angular 2.4中工作

下面是我使用的文件和它们所在的位置:

  • 应用程序/仪表板/ calendar.component.ts
  • 应用程序/仪表板/ calendar.component.html
  • 应用程序/仪表板/omega.theme.css
  • 应用程序/仪表板/ primeng.min.css

这里是我的代码:

calendar.component.ts:

@Component({ 
    moduleId: module.id, 
    selector: 'calendar', 
    templateUrl: 'calendar.component.html', 
    styleUrls: ['omega.theme.css', 'primeng.min.css'] 
}) 
export class CalendarComponent implements OnInit, OnDestroy { 
    ... 
} 

正如你所看到的,我想omega.theme.css和primeng.min.css只适用于我calendar.component.html文件,但我代码不起作用。我究竟做错了什么?

回答

0

修改URL作为

styleUrls: ['./omega.theme.css', './primeng.min.css'] 
+0

这似乎并没有被任何工作。我期待的样式和前所未有的样式仍然不存在。如果它们正确链接,并且我使用Chrome检查器工具中的“来源”,那么在app/Dashboard /中查找,我不应该在那里看到那些文件吗?我找不到它们。 – Brett

+0

得到404吗? – Aravind

+0

没有。没有404或任何其他类型的错误。 – Brett