On my angular 2 app, I have a completely different layout between my home page and the rest of the app. The rest of the app have only a nav in common.
My url looks like :
http://localhost:4200/ <== this is my home page
http://localhost:4200/cgu <== a page with nav in common
http://localhost:4200/abc <== a page with nav in common
Can someone explain to me the best way to do this ?
I tried to reproduce this solution :
How to switch layouts in Angular2
But it doesn't work, or I made mistake to adapt it to my case.
EDIT:
Finally I tried your solution So I created the navigation.service.ts
@Injectable()
export class NavigationService {
isHomePage: boolean;
}
In my home.component.ts
@Component({
styleUrls: ['home.css'],
templateUrl: './home.component.html',
})
export class HomeComponent {
constructor(private navigationService: NavigationService) {
navigationService.isHomePage = true;
}
}
In my app.component.ts I try to get the isHomePage value:
export class AppComponent {
constructor(private navigationService : NavigationService) {
console.log("HELLO");
console.log(navigationService.isHomePage);
if(navigationService.isHomePage)
console.log("HOME");
}}
navigationService.isHomePage is undefined
What's my mistake ?