Questions tagged [angular-activatedroute]
118 questions
4
votes
1 answer
Angular Activated Route ParamsMap empty depending on where I specify the service in providers
I'm using the ActivatedRoute to get a parameter from my route in an injected service. If I specify the service as a provider in the app module or app component the param map is empty when it gets called. If I specify it as a provider in the…

Brian
- 2,253
- 2
- 23
- 39
3
votes
2 answers
Pass static data to parent resolver from child route
I have a resolver which should run on every route change and should work with data passed to it. That data is different for every route.
enum PageId {
FirstPage = 'firstPage',
SecondPage = 'secondPage'
};
const routes: Routes = [
{
path:…

gr4viton
- 1,434
- 1
- 8
- 21
3
votes
1 answer
Mock Query Params Activated Route with different values
If I have this mock activatedRoute below I can write some tests when type is 'mismatch', but if I want to write some tests where type is 'admin-mismatch'. How do I change the value of the the query params?
await…

Dezque
- 53
- 7
3
votes
0 answers
ionic4 Angular 7 query params subscribe is not triggering on every change when using ion-router-outlet
This is my code
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Params, Router } from '@angular/router';
@Component({
selector: 'app-landing',
templateUrl: './landing.page.html',
styleUrls:…

e.k
- 1,333
- 1
- 17
- 36
2
votes
1 answer
error : Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class
I had this message when I've tried to ng serve, and I don't know what this means and what I should do, someone can help?
Error: node_modules/@angular/router/router.d.ts:54:22 - error NG6002:
Appears in the NgModule.imports of AppModule, but could…

diana
- 23
- 1
- 1
- 5
2
votes
2 answers
Route query parameters is empty on first render in Angular
I have a scenario in which I decide the actions based on the query parameters of the angular url.
For example, if the url is localhost:4200/token=abc I need to do some tasks and if the url is localhost:4200 then I need to do something else. I have…

Swapnil Sourabh
- 459
- 4
- 17
2
votes
0 answers
Angular Router - Data missing within lazy loaded modules
I have a module with the routes defined something like below.
const routes: Routes = [
{
path: '',
pathMatch: 'full',
component: RoleListViewComponent
},
{
path: RolesRoutes.addNewRole,
component: ManageRoleComponent,
…

user3602300
- 129
- 7
2
votes
2 answers
activatedRoute returning empty object
I have a routing module that has routes set up for a number of other modules, that I've managed to use activatedRoute for with no problems. But I've now created a singular component and it is returning an empty object when I try and use…

SkinnyBetas
- 461
- 1
- 5
- 27
2
votes
3 answers
How can a service subscribe to the ParamMap of the current route?
I would like to create a service that subscribes to changes in Angular's paramMap. Unfortunately this doesn't seem to work.
export class LocationResourcesService {
constructor(private activatedRoute: ActivatedRoute) {
…

Peter Nixey
- 16,187
- 14
- 79
- 133
2
votes
2 answers
Can not retrieve route params from a component inside mat-sidenav in Angular
when I put my component inside a mat-sidenav I can't get the route parameters
this.route.paramMap.pipe(
tap(params => console.log(params)),
switchMap((params: Params) => {
...
})
).subscribe(
...
);

Smaillns
- 2,540
- 1
- 28
- 40
2
votes
0 answers
Angular - ActivatedRoute in click event
I am using ActivatedRoute to call the summary table from one component to another component and I added below I am not able to get the summary table as expected in click event
tab-routing.module.ts
import { NgModule } from '@angular/core';
import {…

Gem
- 513
- 2
- 6
- 17
2
votes
1 answer
How pass parameters from two url without show them in the url
I need to pass parameters from URLA o urlB whithout and the urlB must be show ( so I can't use skiplocation=true).
in my ts I do ( in URLA) :
this.router.navigate([URLB], {
queryParams:
{
name:…

poopp
- 1,297
- 2
- 13
- 23
2
votes
5 answers
Best way to fetch a route parameter with Angular
What is the best way to take the value of my id in the current route (with ActivatedRoute or Router) ? And explain why :)
n°1
constructor(private route: ActivatedRoute) {}
ngOnInit() {
this.id =…

Tim
- 162
- 2
- 10
2
votes
0 answers
Angular access to headers from activatedRoute (or similar?)
I tired looking around but couldn't find any solution.
From Angular (using v7), how can I retrieve the request HEADERS from an activatedRoute?
My use case is that an authentication provider calls my Angular page and provides the uuid of the user…

Qualaelay
- 713
- 2
- 10
- 21
2
votes
2 answers
Injecting ActivatedRoute gives cyclic dependency error
I'm trying to use ActivatedRoute in an app-root scoped service but getting a Cyclic dependency error I don't understand and don't know how to troubleshoot.
In my application I have a service to get the Community from a top level route…

Boris Callens
- 90,659
- 85
- 207
- 305