Questions tagged [angular-activatedroute]

118 questions
2
votes
4 answers

Unable to access a route parameter through route.snapshot in root component

I want to get token from url but it return null as value. app.component.ts: import { Component, OnInit } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; @Component({ selector: 'app-root', templateUrl:…
2
votes
2 answers

Get current active child component in Angular 6

I'm using Angular 6. I have created a deep routing in my application where app.module a declaration with component AdminLayout @NgModule({ declarations: [ AppComponent, AdminLayoutComponent, ], imports: [ BrowserModule, …
Anuj TBE
  • 9,198
  • 27
  • 136
  • 285
2
votes
1 answer

How to get some segment data of activated route? [Angular 6]

I want to get data of activated route by segment to check if it's company_id !== null: /company_type/company_name/company_id/some_page I tried const prefix = this.activatedRoute.url;. But it's giving long data. I want to get segment data of…
Nodira
  • 656
  • 1
  • 9
  • 23
2
votes
1 answer

How can I add segments to ActivatedRoute?

In angularJS, when using UI-Router, you were able to essentially name routes as each state had a name and you could navigate to that route. For example: $stateProvider.state("base", { url: "/", controller: "baseController" }); and then to navigate…
Justin
  • 683
  • 8
  • 24
1
vote
0 answers

In angular whats is the whole purpose of an active route?

I tried to look in the documentation but I didn't get it fine ! I directly expected routerLinkActive directive to have default classes to just show up button as active on hover or after click
1
vote
2 answers

Angular 15 Activated Route snapshot params get () returns null?

I'm new in Angular and i'm blocked since two days. The command "const pokemonId: string|null = this.route.snapshot.paramMap.get('id');" returns null to pokemonId but normally it gives me the string from the URL (http://localhost:4200/pokemon/4) like…
1
vote
2 answers

How to update this.router.url property based on some condition in Angular

I am working on angular application where I want to update router url on some condition. below is the sample code:- console.log(this.router.url) // it prints '/users' this.location.replaceState('/users/1') // it updates the url bar with new…
1
vote
1 answer

Angular 12 ActivatedRoute get always undifined

A make a code according to a tutorial but me doesnt work because the activatedRoute params always empty even though i change the url.Maybe its changed in Angular 12 because the the tutorial was in version 11.Im comming from react and i am beginner…
1
vote
2 answers

hide component in Angular in certain dynamic route

I need to hide certain components from my main home page like the navbar and footer when I'm logged in to my admin panel. My admin components are lazy-loaded based on an admin module when called. The necessary components are getting hidden as…
1
vote
2 answers

Angular Test Jest - TypeError: Cannot read property 'queryParams' of undefined

I've seen the same error in other posts but they didn't work for me. I have an Angular component, where I need to read a queryParam from the url, for example in http://localhost:4200/sample-page?page=3 I want to stores the number 3 into a component…
1
vote
0 answers

Angular reactive formarray returns first Index value as a null object

In my Angular form while moving from one form to another the formControl can not rendering it's particular value instead it is displaying last visited form values. Eg. If I have visited product_id = 1 and there the formControl('productValue') having…
TMA
  • 1,419
  • 2
  • 22
  • 49
1
vote
0 answers

ActivatedRoute always pointing to root in NgRx Effect

I am trying to figure out why my ActivatedRoute in an ngrx effect is always pointing to root, its ".url" always return Observable of path: ''.
user2167582
  • 5,986
  • 13
  • 64
  • 121
1
vote
1 answer

How to mock ActivatedRoute in Angular without using TestBed

The question is pretty simple. I have never really liked how the original testing works in Angular (the TestBed part), so I have always done it the classic way: mocking with ts-mockito. No TestBed, no configuration needed, zero confusion. I even use…
Javi Marzán
  • 1,121
  • 16
  • 21
1
vote
2 answers

Should i unsubscribe from ActivatedRoute when calling subscribe method within a Router subscription?

I've read that normally you don't have to unsubscribe from Router or ActivatedRoute explicitly because: The ActivatedRoute and its observables are insulated from the Router itself. The Router destroys a routed component when it is no longer needed…
Maurice
  • 6,698
  • 9
  • 47
  • 104
1
vote
2 answers

How to access query params from a url using activated router in angular?

I need to access the current url with query params using an activate router. constructor(private router: Router, private route: ActivatedRoute) { } ngOnInit() { this.router.events.pipe( filter((event: RouterEvent) =>…
Karu
  • 935
  • 2
  • 13
  • 32