As I am new to angular 2/4 I am having trouble setting up a new application as per my need.
I am trying to build an application which will be called for from some anothe
import { Component, OnInit, OnDestroy } from '@angular/core';
import { Router, ActivatedRoute, Params, RoutesRecognized } from '@angular/router';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
constructor( private route: ActivatedRoute, private router: Router ) {}
ngOnInit(): void {
this.router.events.subscribe(val => {
if (val instanceof RoutesRecognized) {
if (val.state.root.firstChild.params.id) {
localStorage.setItem('key1', val.state.root.firstChild.params.id);
localStorage.setItem('key2', val.state.root.firstChild.params.id2);
}
console.log('test', val.state.root.firstChild.params);
}
});
}
}