Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Router does not allow users to navigate to a route in the address bar unless a link is added some where in the page #8481

Closed
rahulbats opened this issue May 5, 2016 · 9 comments

Comments

@rahulbats
Copy link

rahulbats commented May 5, 2016

So i realized this, i have to add a router link to my page to get the routes to work.
<a [routerLink]="['/heroes']">Heroes</a>

Now if i type http://localhost:4200/heroes i actually get to the heroes page. If i remove the link from my page typing it in address bar does not load the route content.

Please refer to this thread

@cexbrayat
Copy link
Member

cexbrayat commented May 5, 2016

I'm running into a similar issue (new router in rc.1).

@ericmartinezr
Copy link
Contributor

Related to #8409 ?

@luxueyan
Copy link

luxueyan commented May 6, 2016

Me too

@yfain
Copy link

yfain commented May 6, 2016

We have an app with a page that has several components, and one of the children had a [routerLink] to open a specific component. It used to work fine with old router. After upgrading the app to RC.1, this page didn't render half of the components without reporting any errors.

After we've added unneeded <a [routerLink]="['/']">My page</a> to one of the components the page rendered correctly.

This is clearly a bug in the router.

@ps2goat
Copy link

ps2goat commented May 10, 2016

+1 - a lot of broken router features.

@blackheart01
Copy link

blackheart01 commented May 13, 2016

I'm having the same problem. The routerLink doesn't even have to link to a valid route. It just has to exist.
Ex.
<a [routerLink]="['/it_does_not_matter_what_is_in_here']">ABOUT</a>

@blackheart01
Copy link

I'm able to remove the routerLinks all together if I inject Router into the top level app.component:

import { Component } from '@angular/core';
import { ROUTER_DIRECTIVES, Routes, Router } from '@angular/router';

import { AboutComponent } from './+about/index';
import { HomeComponent } from './+home/index';
import { NameListService, ToolbarComponent, NavbarComponent } from './shared/index';

@Component({
  selector: 'sd-app',
  viewProviders: [NameListService],
  templateUrl: 'app/app.component.html',
  directives: [ROUTER_DIRECTIVES, ToolbarComponent, NavbarComponent]
})
@Routes([
  {
    path: '/',
    component: HomeComponent
  },
  {
    path: '/about',
    component: AboutComponent
  }
])
export class AppComponent {
  constructor(private router: Router) { }
}

@IgorMinar
Copy link
Contributor

This issue was made obsolete by router v3: https://angularjs.blogspot.com/2016/06/improvements-coming-for-routing-in.html

If you believe this is not the case, please file a new issue updating the description to router v3. thank you!

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants