Questions tagged [angular2-router]
119 questions
3
votes
1 answer
Angular2: AuthGuard not working when using browser navigation buttons
I've got a simple AuthGuard configured, that works perfectly fine when navigating "normally" through the application (see code below).
Now imagine following:
User navigates to /content/secured-content, which requires authentication => he is being…

Naduweisstschon
- 78
- 5
3
votes
2 answers
Switch and persist selected tab of ng2-bootstrap , using Angular router
I have a component showing tabs using ng2-bootstrap tabset and tab.
Example:

hgoebl
- 12,637
- 9
- 49
- 72
3
votes
1 answer
Set activatedRoute optional param "id" without navigating at all
I have a search filter page that displays products of the search, and also displays the product details in a modal when the user clicks on a product of the search.
I want to now set the existing id optional param of the activatedRoute…

BeniaminoBaggins
- 11,202
- 41
- 152
- 287
3
votes
3 answers
Child component not updating on parent route change
I have been trying to learn angular 2 following along with this tutorial [Build an application with Angular 2 and Firebase][1] and trying to extend on it. But I have hit a snag when trying to nest multiple routes.
App structure:
Goals – (has…

Daimz
- 3,243
- 14
- 49
- 76
3
votes
1 answer
Loading Routes via JSON in Angular2
I am trying to load the routes from a JSON file, as i do not want to hard code them and load the routes lazily.
Something like this:
import { RouterModule } from '@angular/router';
const routes = [
{ path: '', loadChildren:…

bhaskar roy
- 31
- 4
3
votes
1 answer
Angular2 - Extending router and Observable
In angular2 rc2 with the router module v 3.0.0.6alpha, I extend the RouterOulet to check if the user is logged in before accessing the admin. So this is the code :
@Directive({
selector: 'router-outlet'
})
export class LoggedInRouterOutlet…

Adam S
- 1,021
- 1
- 14
- 25
3
votes
1 answer
ComponentInstruction and CanActivate are not available in angular 2 rc1
I'm writing an angular2 application using typescript with angular 2 rc.1
I'm guessing that the angular 2 documents are not updated yet.…

ufk
- 30,912
- 70
- 235
- 386
2
votes
1 answer
Angular: Differentiate between a parameter and child route
I have a situation where, I want a resolver if the child route is a param, and not if it's a path segment. Below is my code.
{
path: 'agreement',
children: [
{
path: ':id',
component: AgreementComponent,
…

karthikaruna
- 3,042
- 7
- 26
- 37
2
votes
1 answer
Getting the correct url in router events
I have the following configuration of routes:
{ loadChildren: './public#PublicModule', path: '' },
{ loadChildren: './home#HomeModule', path: 'home' },
{ path: '**', redirectTo: '/404' }
In some template (if it matters, let's call it…

dev_054
- 3,448
- 8
- 29
- 56
2
votes
0 answers
Button need to be clicked twice to set a right input value angular2
I tried to make a search system like this
2
votes
1 answer
How to make Angular 2 remember scroll position?
I'm on page 1, I scroll halfway through the page and then click a link that brings me to page 2 through the Angular router. When I hit the "back" button, I'd like page 1 to be scrolled halfway down, just like it was before I left that page.
What is…

alcfeoh
- 2,147
- 1
- 18
- 33
2
votes
2 answers
Angular 2 route guard isn't waiting for value to be set
I've got this route guard which should check the user's role as well as a roleAccess property defined in the route definition.
The problem I'm facing is that .map executes regardless of accounts.isSelfPending, only when that is false (it starts off…

Chrillewoodz
- 27,055
- 21
- 92
- 175
2
votes
1 answer
Currious 'state' query param behaviour with angular2 Router
I don't find any documentation on this precious behaviour of Angular 2 Router : if I load my app with a 'state' query param, the router automatically navigates to the given state.
I found this by chance looking for a solution to my problem, but I…

Karbos 538
- 2,977
- 1
- 23
- 34
2
votes
0 answers
Error in Component class Component - inline template:7:24 caused by: Cannot read property 'subscribe' of undefined
I use angular 2.1.0 modules in my current application. I get the error below if i run unit test on a component that has a routerLink attribute.
Failed: Uncaught (in promise): Error: Error in ./MyComponent class MyComponent - inline template:7:24…

Sara
- 36
- 6
2
votes
0 answers
Angular 2 router i18n url
I'm currently developing a web app based on Angular 2.1.0.
I received some instructions by the SEO specialist regarding the way I need to set the different urls (based on the language used), for example :
http://www.example.com/actualite // french…

kinkaz
- 53
- 8