Angular2 router, get route data from url, to display breadcrumbs

后端 未结 3 1781
误落风尘
误落风尘 2020-12-01 08:19

I am using angular2 router.

To draw the breadcrumb of an url, lets say site.com/a/b/c/15 I do the following:

  1. Get the route of site.com/a/b/c/15
3条回答
  •  不思量自难忘°
    2020-12-01 08:48

    So far, the most feasable solution is (done):

    • Make the routes export/importable
    • Get the current url update from router.events subscribe
    • On url change, loop on the routes's path, see if the pattern match the url
    • If the patter match the url, get the data from the matching route

    Pros: works

    Cons: redoing url-route recognition manuall without using the ng2 router one

提交回复
热议问题