2017-06-20 166 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