2017-07-09 33 views
1

剛纔我「寫」得到一個角度編譯錯誤(複製結構沒有內容)這個小角4模塊:爲什麼我在這個簡單的組件

import { BrowserModule } from "@angular/platform-browser"; 
import { NgModule } from "@angular/core"; 
import { FormsModule } from "@angular/forms"; 
import { HttpModule } from "@angular/http"; 

import { FooterComponent } from "./footer.component"; 

@NgModule({ 
    declarations: [ 
    FooterComponent 
    ], 
    imports: [ 
    BrowserModule, 
    FormsModule, 
    HttpModule 
    ], 
    providers: [], 
    bootstrap: [FooterComponent] 
}) 
export class FooterModule { } 

當我嘗試的angular build,我得到以下錯誤:

ERROR in C:/Projects/Angular 4/Angular4/src/footer.module.ts (7,1): 'from' expected.

對我來說,7號線,import { FooterComponent } from "./footer.component";,看上去語法正確,甚至有一個from。如果from組件不好,我寧可期待運行時錯誤。

+0

您是否嘗試刪除並重寫(而不是複製過去)此行和之前的行? – Guy

+0

嘗試清理緩存並重新啓動 – Sajeetharan

+0

@Guy,是的,我做到了。 – ProfK

回答

1

事實證明,我沒有爲我的組件包含*.Module.ts。這是絆倒了import's和各種事情。我在組件裝飾器下面看到一條紅線,盤旋在線告訴我我的模塊不能在這裏和那裏使用。

添加模塊文件解決了問題。

1

鍵入以下內容:

import { } from "./footer.component"; 

然後將光標放在花括號內,然後按Ctrl-空間,在你的IDE。看看它是否建議FooterComponent。如果不是,則問題出現在footer.component.ts中。

相關問題