I want to use my app as an iframe on other web pages. However, therefore I need a 'stripped' version of my app, where some features are disabled.
Normally, I navigate with url/#/... For the iframe, it is url/#/iframe/... . They both navigate to the same pages, although some features are disabled in the latter.
My problem is that I want to place a div around the router-outlet with a class depending on whether I'm in iframe-mode or not. At this moment, I can only think of checking
this.route.snapshot.url[0].path === 'iframe'
in the car.component.ts file, storing this value somewhere in app.service.ts as appService.iframe and then using this value in app.component.html.
This, however, gives the following error:
ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'body1'. Current value: 'body2'.
Can I get the url before loading the router?
app.routes.ts file:
// Route Configuration
export const routes: Routes = [
{path: '', component: CarList},
{path: 'iframe', component: CarList},
{path: 'iframe/:loket', component: Car},
{path: ':loket', component: Car}
];
// Export routes
export const routing = RouterModule.forRoot(routes);
app.component.html file:
<div class="container">
<div class="header">
<header></header>
</div>
<div [ngClass]="(!appService.iframe) ? 'body1': 'body2'">
<router-outlet></router-outlet>
</div>
<div class="footer">
<footer></footer>
</div>
</div>
location.hashvalue and check from therethis.appState.iframe = location.hash.includes("iframe")in the constructor of app.component.ts!