简体   繁体   中英

Routing in app with firebase doesn`t work correct

https://github.com/Wilkuuu/Biblio

In Books component in html i`ve :

<a 
  routerLink="/books/{{book.id}}" 
  class="btn btn-secondary btn-sm">
  <i class="fa fa-file"></i>
</a>

in app-routing :

{ path: 'book/:id', component: BookDetailComponent }

In URL i see an id from firebase, but the path provides me to :

{ path: '**' , component: NotfoundComponent },

Just have a look at your route config:

{ path: 'book/:id', component: BookDetailComponent }

The route that you should be using is book/ and not books/

routerLink="/books/{{book.id}}"

should be

routerLink="/book/{{book.id}}"

And yeah, as mentioned by Andrei, the catch-all route(the one with path: '**' ) should be the last route in your route config.

Ofc problem solved. {path: '**' , component: NotfoundComponent}, must be the last one. Ty !

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM