deeleman / learning-angular2

Code samples repository for the examples provided in "Learning Angular 2", published by Packt Publishing - THE BOOK COVERS UP TO RC.1 and hence is severely OUTDATED. PLEASE REFER TO THE LATEST EDITIONS INSTEAD.
https://www.packtpub.com/web-development/learning-angular-2
108 stars 59 forks source link

Chapter 7 Section 3 - Routing failing #37

Closed RichLinnell closed 8 years ago

RichLinnell commented 8 years ago

Once I have made the initial set of changes to add the index to the timer route, you say refresh and see the link being passed, but actually the whole app fails with

EXCEPTION: Error in app/app.component.html:7:10 browser_adapter.ts:78 ORIGINAL EXCEPTION: Route generator for 'id' was not included in parameters passed.

I have to remove the link to the timer from the main menu to get it to load again.

deeleman commented 8 years ago

Please check if there's any inconsistency between your code and these two lines at tasks.component.html

RichLinnell commented 8 years ago

No, those lines are good, it's the following line in app.component.html that is causing the issue

<li><a [routerLink]="['TimerComponent']">Timer</a></li>

if I change it to this, then all is good (sort of)

<li><a [routerLink]="['TimerComponent', {id: 0}]">Timer</a></li>

gtstewart commented 8 years ago

There is no id identifier in app.component.html. In app.component.ts the RouteConfig for the timer should be { path: 'timer/:id', name: 'TimerComponent', component: TimerComponent //create page 203 }

deeleman commented 8 years ago

There is no id identifier in app.component.html. In app.component.ts the RouteConfig for the timer should be { path: 'timer/:id', name: 'TimerComponent', component: TimerComponent //create page 203 }

This piece of code is outdated now that Angular 2 Final contains Router 3.0. For the record, and since providing support for outdated code is pointless, I am working on an updated version of the code, fully compliant with Angular 2 Final.

Closing this issue in the meantime. Feel free to post further comments if required.