2017-02-15 43 views
-2

我正在做Angular的教程(教程:英雄之旅),但卡住了,希望得到一些幫助。角度教程不工作在第5章(路由)

我在第五章(ROUTING),繼續研究,直到「重構路由到路由模塊」。 在這一點上,我想我可以通過執行npm start看到我的代碼在瀏覽器上工作,但屏幕停止在Loading AppComponent content here ...

我已將我的教程代碼上傳到GitHub(https://github.com/btfurukawatkr/angular-tour-of-heroes)。 任何人都可以幫我解決我做錯了什麼嗎?

教程:https://angular.io/docs/ts/latest/tutorial/toh-pt5.html

+1

您的控制檯出現錯誤。你爲什麼不在你的問題中提供它? – echonax

+0

實際上,當我執行'npm start'時,我沒有注意到任何錯誤,所以這就是讓我困惑的原因 – guchuan

+0

您應該從瀏覽器控制檯添加錯誤消息) – Saka7

回答

1

正如你可以在開發者控制檯Can't bind to 'hero' since it isn't a known property of 'my-hero-detail'.錯誤是<my-hero-detail [ERROR ->][hero]="selectedHero"></my-hero-detail>因爲你沒有在HeroDetailComponent添加@Input裝飾到hero屬性看。您還沒有將<base href="/">加入index.html

hero.detail.component.ts

import { Component, OnInit, Input } from '@angular/core'; 
//... 

@Component({ 
    moduleId: module.id, 
    selector: 'my-hero-detail', 
    templateUrl: './hero-detail.component.html' 
}) 
export class HeroDetailComponent implements OnInit { 
    @Input() private hero: Hero; 
    //... 
} 

的index.html

<!DOCTYPE html> 
<html> 
    <head> 
    <!-- ... --> 
    <base href="/"> 
    <!-- ... --> 
    </head> 
    <body> 
    <my-app>Loading AppComponent content here ...</my-app> 
    </body> 
</html> 

Component Communication教程。

+0

''做了修復。謝謝你的評論。 – guchuan