Following tutorial here: https://angular.io/docs/ts/latest/tutorial/toh-pt6.html
Current Code: https://github.com/GreenAnts/Angular2-tour-of-heroes-tutorial
(Note: http must be working, as I am able to view heroes, and dashboard, which are viewing the heroes. . . it is only when I view hero details, which doesn't make sense to me, as I never changed the hero detail methods that I can think of.)
Errors when trying to view hero-details:
I don't know what it is, I am assuming it must be something simple I am overlooking, but I really can't figure it out, any help would be much appreciated as I am stuck.
I am at the point in the tutorial where it says this:
Update hero details
We can edit a hero's name already in the hero detail view. Go ahead
and try it. As we type, the hero name is updated in the view heading.
But when we hit the Back button, the changes are lost!
Updates weren't lost before, what's happening? When the app used a
list of mock heroes, changes were made directly to the hero objects in
the single, app-wide shared list. Now that we are fetching data from a
server, if we want changes to persist, we'll need to write them back
to the server.
It turned out to be much simpler, I should have looked there first. Doh!
Your baseHref was empty. It was:
<base href="" />
And should have been:
<base href="/" />
Some other things that you might want to fix:
Currently:
getHero(id: number): Promise<Hero[]> {
return this.getHeroes()
.then(heroes => heroes.find(hero => hero.id === id))
}
Should be:
getHero(id: number): Promise<Hero> {
return this.getHeroes()
.then(heroes => heroes.find(hero => hero.id === id))
}
The HTML and Style URLs won't always work as defined:
templateUrl: './templates/app.component.html',
styleUrls: ['./styles/app.component.css']
Pre-pend 'app' in front like this:
templateUrl: 'app/templates/app.component.html',
styleUrls: ['app/styles/app.component.css']