2017-02-15 54 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