Questions tagged [angular2-router3]
90 questions
272
votes
9 answers
How to pass a parameter to routerLink that is somewhere inside the URL?
I know I can pass a parameter to routerLink for routes such as
/user/:id
by writing
[routerLink]="['/user', user.id]"
but what about routes such as this one:
/user/:id/details
Is there a way to set this parameter or should I consider a different…

Thorsten Westheider
- 10,572
- 14
- 55
- 97
118
votes
5 answers
Do I have to unsubscribe from ActivatedRoute (e.g. params) observables?
I find many examples where ActivatedRoute Observables like params or url are subscribed but not unsubscribed.
constructor(private route: ActivatedRoute) {}
ngOnInit() {
this.route.params
// (+) converts string 'id' to a number
…

hgoebl
- 12,637
- 9
- 49
- 72
70
votes
7 answers
How to route to a Module as a child of a Module - Angular 2 RC 5
I am in the process upgrading an application I'm working on to the latest Angular 2 release candidate. As part of this work I am attempting to use the NgModule spec and migrating all of the parts of my application to modules. For the most part, this…

John Ackerman
- 1,041
- 1
- 9
- 16
32
votes
12 answers
Can't reload/refresh active route
I have recently updated to the new RC3 and Router3alpha and it seems some things have changed.
I noticed that a click on the link of an active route does no longer result in the component to be reloaded. How do I achieve this behaviour with the new…

TommyF
- 6,660
- 8
- 37
- 61
19
votes
4 answers
Angular 2 throwing error: Outlet is not activated
I have set up my app so that I have a Recipe Book which has a list of Recipies which when I click on a Recipe it then shows the Recipe Details in a nested route. This then also has a button that when clicked loads the ingredients in a nested route…

Daimz
- 3,243
- 14
- 49
- 76
19
votes
1 answer
Angular2 Router: Cannot find primary outlet to load 'HomeComponent'
tried to switch to new Router as in version "@angular/router": "3.0.0-beta.2" in combination with "@angular/*": "2.0.0-rc.4", following the official docs on the ComponentRouter.
However, I'm facing an issue when trying to load my App with the…

Thorsten Viel
- 1,199
- 1
- 10
- 18
18
votes
3 answers
No provider for ActivatedRoute - Angular 2 RC5
After upgrading to Angular 2 RC5 (from RC4) it seems I can no longer inject ActivatedRoute into my components.
ORIGINAL EXCEPTION: No provider for ActivatedRoute!
Here's the relevant piece of code:
import { Component } from…

Thorsten Westheider
- 10,572
- 14
- 55
- 97
14
votes
2 answers
Want to prevent Component recreation while routing in Angular 2
Let's say we have two routes Dashboard and Profile. Dashboard has dynamic tabs feature like Google spreadsheet. I want to do some interactions(build charts, visualizing some data) creating tabs in the Dashboard. Now, if I route to Profile and then…

pd farhad
- 6,352
- 2
- 28
- 47
14
votes
2 answers
How to handle hash fragments from oauth redirect urls in Angular2 rc3 routing
I'm trying to find a way to handle setting up an Angular2 Typescript route (using the 3.0.0-alpha.8 router) that will handle routes that begin with hash fragments.
The app I'm working on handles all login externally (something I have no control…

NColey
- 525
- 1
- 6
- 18
11
votes
1 answer
Angular2 Routing : Loading twice
I am using Angular2 with routing and my page is showing duplicate content on initial load. Once i click any Link(Page1 or Page2) everything works perfect(there is no more duplicate content). Why am i getting the duplicate content on initial load and…

user3799325
- 590
- 1
- 8
- 20
11
votes
5 answers
Angular2 how to set app root path independently from html base url
I'm building an angular2 application/widget that will be embedded into TYPO3 as a plugin that can be inserted on any content page. This means it could end up at different root paths e.g.:
/page1/app
/page/subpage/subpage/whatever
The global base…

jdachtera
- 749
- 1
- 6
- 11
8
votes
1 answer
Parallel (Asynchronous Non Blocking) Routing In Angular 2/4
The application has a page with 2 to 3 category buttons. Basically, button click will pull the list of items in each category, the page should be shown once API fetched data is available.
I have designed angular 2 app routes with resolve API calls…

newstackoverflowuser5555
- 741
- 2
- 11
- 31
8
votes
3 answers
How do I Mock an Angular 2 route?
I have the following code...
export class LoginComponent {
userName: string;
password: string;
rememberMe: boolean = false;
constructor( private auth: AuthenticationService,
private router: Router) {
...
}
…

Jackie
- 21,969
- 32
- 147
- 289
8
votes
3 answers
Return Observable in canDeactivate not working
I have a confirm/cancel modal dialog that pops up when a user leaves a route. I do this by using a guard with the canDeactivate method. However I want canDeactivate to wait until it gets a response from the modal before returning anything.
I have…

Mark Letters
- 323
- 5
- 14
8
votes
2 answers
How can I specify query parameters by routerLink directive
I am experimenting the new router (version 3.0.0-alpha.7) and would like to know how to specify query parameters by routerLink directive?
The Router.navigate() method below generates a URL like…

Yuan Li
- 205
- 1
- 3
- 7