I am building an Angular 7 app. In this app I got nested routes. I want to be able to detect what component the parent route is using. I found a way of doing it locally but this does not work on production (output is different).
I use this method:
checkIfChild() {
this.sub = this.route.parent.params.subscribe(params => {
if (params['id']) {
this.parentId = params['id'];
if (this.route.parent.component['name'] === 'ProjectShowComponent') {
this.parentType = 'Project';
} else if (this.route.parent.component['name'] === 'CompanyShowComponent') {
this.parentType = 'Company';
} else if (this.route.parent.component['name'] === 'ContactShowComponent') {
this.parentType = 'User';
}
}
});
}
The method, this.route.parent.component['name'], outputs the name locally but just the letter T on production.
I get this message instead
TypeError: 'arguments', 'callee', and 'caller' cannot be accessed in this context.
What is the right way of detecting what parent route has activated the child route so that I can act on it?