I'm new to angular 6. I have been using angularjs for years though. I trying to work out routing and structuring the application. I want to be able to access a route value in app.compnent. I have the template of my site here and based on a route parameter i need to be able to change the theme. I have a route parameter called modulePath that will always be present in all routes. As app.component contains the router outlet though it seems its not able to access the route values. Any help on this would be appreciated. Perhaps I'm going about it the wrong way entirely.
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router, NavigationStart, NavigationEnd} from
'@angular/router';
import { Location } from '@angular/common';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
title = 'Ang';
modulePath: string;
private sub: any;
constructor(
private route: ActivatedRoute,
router: Router,
private location: Location
) {
}
ngOnInit(): void {
this.sub = this.route.params.subscribe(params => {
this.modulePath = params['modulePath'];
console.log(params);
});
}
}