2017-06-20 86 views
1

我采用了棱角分明4.1.3和Rails 5.1角4个styleUrls找不到文件

我想用styleUrls我的成分,但得到的错误。

这是错误。

zone.js?4c9b:643 Unhandled Promise rejection: Failed to load app.component.css ; Zone: <root> ; Task: Promise.then ; Value: Failed to load app.component.css undefined 

这是我的组件。

import { Component } from '@angular/core'; 
import template from './app.component.html' 

@Component({ 
    selector: 'app-root', 
    template: template, 
    styleUrls: ['./app.component.css'] 
}) 

export class AppComponent { 
    name = ''; 
} 

这是我的文件结构

├── app 
     app.component.css 
| ├── app.component.html 
| └── app.component.ts 
| └── app.module.ts 

回答

0

试试这个,

@Component({ 
    moduleId: module.id, 
    selector: 'app-root', 
    template: template, 
    styleUrls: ['app.component.css'] 
}) 
+1

这有什么错'/ app.component.css'? '。/ app.component.html'加载就好了。 – 31piy

+0

'module.id'需要被规定以加载组件的相关资产。这里有一个完整的答案 - > https://stackoverflow.com/questions/37178192/angular2-what-is-the-meanings-of-module-id-in-component – Alexus