angular-activatedroute

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

匆匆过客 提交于 2021-01-24 09:15:57
问题 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 it is getting id properly. The mistake is accessing to element in the right child component, didn't work in child's MatDialog component within the Snapshot version. constructor(private route: ActivatedRoute) {} ngOnInit(): void { console.log

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

☆樱花仙子☆ 提交于 2021-01-24 09:14:09
问题 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 it is getting id properly. The mistake is accessing to element in the right child component, didn't work in child's MatDialog component within the Snapshot version. constructor(private route: ActivatedRoute) {} ngOnInit(): void { console.log

angular 7 getting ActivatedRoute params not working

末鹿安然 提交于 2020-08-24 07:42:28
问题 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 routerLink is clicked. so I have the following: question on stackblitz I can't seem to get it to work. layout.component.ts import { Component, OnInit} from '@angular/core'; import { ActivatedRoute, Router} from '@angular/router'; @Component({

angular 7 getting ActivatedRoute params not working

吃可爱长大的小学妹 提交于 2020-08-24 07:41:45
问题 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 routerLink is clicked. so I have the following: question on stackblitz I can't seem to get it to work. layout.component.ts import { Component, OnInit} from '@angular/core'; import { ActivatedRoute, Router} from '@angular/router'; @Component({

How to use ActivatedRoute in Angular 5?

时光怂恿深爱的人放手 提交于 2020-08-18 14:20:37
问题 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 am unable to figure out what I need to import to be able to use ActivatedRoute. Could someone specify exactly what needs to be added to the app.module.ts file, and the component.ts file where I am trying to use ActivatedRoute? This post specifies

How to use ActivatedRoute in Angular 5?

拜拜、爱过 提交于 2020-08-18 14:20:07
问题 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 am unable to figure out what I need to import to be able to use ActivatedRoute. Could someone specify exactly what needs to be added to the app.module.ts file, and the component.ts file where I am trying to use ActivatedRoute? This post specifies

Angular 6 - Get current route and it's data

夙愿已清 提交于 2020-01-20 21:43:29
问题 How do you able to get current route you're in and get's it's data, children and it's parent? say if this is the route structure: const routes: Routes = [ {path: 'home', component: HomeComponent, data: {title: 'Home'}}, { path: 'about', component: AboutComponent, data: {title: 'About'}, children: [ { path: 'company', component: 'CompanyComponent', data: {title: 'Company'} }, { path: 'mission', component: 'MissionComponent', data: {title: 'Mission'} }, ... ] }, ... ] If I am currently in

Angular 2 get parent activated route

。_饼干妹妹 提交于 2020-01-11 08:43:08
问题 I have a route with route children like this: { path: 'dashboard', children: [{ path: '', canActivate: [CanActivateAuthGuard], component: DashboardComponent }, { path: 'wage-types', component: WageTypesComponent }] } And in the browser I want to get the activated parent route like host.com/dashboard/wage-types How to get the /dashboard but possible with Angular 2 and not in JavaScript, but also I can accept JavaScript code too but primary Angular 2. 回答1: You can do this by using the parent

Angular Activated Route ParamsMap empty depending on where I specify the service in providers

微笑、不失礼 提交于 2019-12-13 19:17:11
问题 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 component that pulls in the service it has the parameter. Why is this working this way. I've had trouble finding good information on how the ActivatedRoute is scoped and how it interacts with services. Link to this behavior in plnkr. Uncomment line 11

Angular 2 get parent activated route

强颜欢笑 提交于 2019-12-01 21:04:06
I have a route with route children like this: { path: 'dashboard', children: [{ path: '', canActivate: [CanActivateAuthGuard], component: DashboardComponent }, { path: 'wage-types', component: WageTypesComponent }] } And in the browser I want to get the activated parent route like host.com/dashboard/wage-types How to get the /dashboard but possible with Angular 2 and not in JavaScript, but also I can accept JavaScript code too but primary Angular 2. peppermcknight You can do this by using the parent property on the ActivatedRoute - something like this. export class MyComponent implement OnInit