Questions tagged [angular-activatedroute]

118 questions
40
votes
10 answers

Angular : Get value of parameter in parent route

I am having URLs like www.yoursite.com/accounts/:accountid/info www.yoursite.com/accounts/:accountid/users etc. An integer value accountid is available in the URL But can't access it using the ActivatedRoute parameters. Now I am splitting the URL…
jophab
  • 5,356
  • 14
  • 41
  • 60
37
votes
1 answer

Angular error: no provider for ActivatedRoute

i m using angular 5 latest and i am hitting below exception ERROR Error: StaticInjectorError(AppModule)[AppComponent -> ActivatedRoute]: StaticInjectorError(Platform: core)[AppComponent -> ActivatedRoute]: NullInjectorError: No provider for…
Vik
  • 8,721
  • 27
  • 83
  • 168
16
votes
4 answers

Angular 6 - Get current route and its data

How to get the current route you're in and its data, children and parent? If this is the route structure: const routes: Routes = [ {path: 'home', component: HomeComponent, data: {title: 'Home'}}, { path: 'about', component:…
jedion
  • 624
  • 1
  • 7
  • 18
15
votes
5 answers

How to use ActivatedRoute in Angular 5?

I am trying to do exactly the same thing as in this post: Angular 4 get queryString I am using Angular 5.2.5. ActivatedRoute seems to be the thing to use to retrieve querystring values off the URL when the user first visits the website. However, I…
Mark Nugent
  • 599
  • 2
  • 5
  • 20
9
votes
1 answer

angular 7 getting ActivatedRoute params not working

Hi and thank you for your help in advance. I have been working on this problem for awhile now and have not been able to figure it out yet. What I want to do is to access the params and display what is selected on the page. It doesn't fire when the…
Natdrip
  • 1,144
  • 1
  • 11
  • 25
9
votes
3 answers

Angular 2 get parent activated route

I have a route with route children like this: { path: 'dashboard', children: [{ path: '', canActivate: [CanActivateAuthGuard], component: DashboardComponent }, { path: 'wage-types', component:…
user4208442
8
votes
1 answer

Angular, get parent route component

I am building an Angular 7 app. In this app I got nested routes. I want to be able to detect what component the parent route is using. I found a way of doing it locally but this does not work on production (output is different). I use this method: …
Jonathan Clark
  • 19,726
  • 29
  • 111
  • 175
7
votes
2 answers

How to redirect unknown routes to home route in Angular program?

I have a routes.ts file like below: import { AuthGuardService as AuthGuard } from '../services/auth-guard.service'; export const routes:Routes = [ {path : '' , redirectTo : '/home' , pathMatch : 'full'}, {path: 'home' , component :…
Hasani
  • 3,543
  • 14
  • 65
  • 125
6
votes
2 answers

ActivatedRoute.snapshot.paramMap not working

I trying to get a route param on startup/initial route. But it is not working. app.component.ts import { ActivatedRoute } from '@angular/router'; ... constructor( private activatedroute: ActivatedRoute ) {} ngOnInit() { …
Frank
  • 2,109
  • 7
  • 25
  • 48
5
votes
3 answers

ActivatedRoute does not update the child route data on route changes

I'm tying to get the child route data('layout') from parent component using ActivatedRoute. I have tried the following example and I'm able to get the data I'm looking for but only for one time. During child route changes, I don't see the updated…
Body
  • 3,608
  • 8
  • 42
  • 50
5
votes
3 answers

List of queryParams is empty in Angular 5 routing

I'm new to Angular and I've looked for solution of my problem, but unfortunately I haven't found that. When I 'm passing parameters to the router (class Router), but list of params (on target site) is empty. let navigationExtras: NavigationExtras…
5
votes
4 answers

Check angular route path from interceptor

I have a route path configured as: { path: 'user/:id/edit/:type', component: UserEditTypeComponent, }, I want to reach the path from the interceptor which i could access from activated routes as: constructor(private activatedRoute:…
PaladiN
  • 4,625
  • 8
  • 41
  • 66
4
votes
1 answer

Jasmine test for ActivatedRoute Angular 7

I am trying to write a simple test for ActivatedRoute. Here's what my test looks like. it("should check if subscribes are called in init", () => { const subRouteSpy = spyOn(activatedRouteStub.paramMap, "subscribe"); component.ngOnInit(); …
Mj1992
  • 3,404
  • 13
  • 63
  • 102
4
votes
5 answers

Why ActivatedRoute.queryParams is not working in Angular?

I am using routing in my Angular app. I have bellow route in my routing module. { path: 'user/:name', component: UserComponent, } I am using queryParams of ActivatedRoute to get name from route. this is my…
user10274935
4
votes
2 answers

How to get id from the URL using snapshot or ActivatedRoute subscriber in Angular?

I am getting value using snapshot method but it is getting the value after "classes" in this case 20 but I need 33 path like getting credits/33/classes/20 only 20 or credits/33/classes/ only null("") Update: I found a solution to my question. Now…
Rahimjon Rustamov
  • 246
  • 1
  • 3
  • 19
1
2 3 4 5 6 7 8