question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incorrect route link parsing in template

See original GitHub issue

I’m submitting a … (check one with “x”)

[ x] bug report

Current behavior routerLink parsing is wrong in template: it includes current path.

Expected behavior It should not include current path rather replace it.

Minimal reproduction of the problem with instructions https://plnkr.co/edit/MYoIl9lWwEYLvd9iezh5?p=preview

  1. Click “Heroes
  2. Click any hero (current route: /hero/XX/)
  3. Click any of the “heroes” or “/heroes” or the “/heroes/” buttons to navigate to those routes
  4. Check the invalid route error message for the route it tried to navigate

The link buttons are generated in app/heroes/hero-detail.component.ts like this:

<div>
      <template ngFor [ngForOf]="columns" let-column>
        <button routerLink="['{{column.routerLink}}']">{{column.routerLink}}</button>
      </template>
    </div>
..
columns: any[] = [
    {
      routerLink: "heroes"
    },
    {
      routerLink: "/heroes"
    },
    {
      routerLink: "/heroes/"
    }]

Error message activatedRoute.snapshot.toString() in app/not-found-component.ts:

Page not found: Route(url:'hero/11/%5B'heroes'%5D', path:'**')

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
DzmitryShylovichcommented, Mar 23, 2017

and, please, read docs https://angular.io/docs/ts/latest/guide/template-syntax.html before submitting issues. thanks

1reaction
DzmitryShylovichcommented, Mar 23, 2017
<div>
      <template ngFor [ngForOf]="columns" let-column>
        <button [routerLink]="column.routerLink">{{column.routerLink}}</button>
      </template>
</div>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does angular parse templates before router resolved is ...
I'm using angular and ng-route and want to handle a simple redirect if some given resolve returns false. However, if the route's template...
Read more >
Resolve template validation or template format errors in ...
For "Invalid template property or properties [XXXXXXXX]" errors, see the Verify template properties section. Resolution. Note: If you receive ...
Read more >
Routing in ASP.NET Core - Microsoft Learn
A route template is used to configure how the endpoint is matched. ... The LinkParser class adds support for parsing a URL path...
Read more >
Routing & Navigation - ts - GUIDE - Angular
It can pass optional parameters along to the supporting view component that help it decide what specific content to present. You can bind...
Read more >
matchPath - React Router v5
This lets you use the same matching code that <Route> uses except outside of the ... optional, defaults to false exact, // optional,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found