I have a Component
that has 2 "view states" (vertical and horizontal).
in order to show\load the users preference i am checking a value of a static boolean property (AppService.IsVerticalView
) that is located in a service.
this is the home component:
@Component({
host: { '(document:scroll)': 'onScroll($event)' },
selector: 'txt-zone',
templateUrl:AppService.IsVerticalView == false ? 'app/txtzone/Txtzone.component.html' : 'app/txtzone/Txtzone_vertical.component.html' ,
styleUrls: [AppService.IsVerticalView == false ? 'app/txtzone/TxtZone.css' : 'app/txtzone/txtZone_Vertical.css'],
})
I am changing AppService.IsVerticalView
value from another component class and loading the page of home component again.
here is the function from the other component:
SwapToVerticalView(): void
{
if (AppService.IsVerticalView == true) {
// change to horizonal
AppService.IsVerticalView = false;
// show you can return to vertical
this.currentViewShape = "Vertical View";
}
else
{
// change to vertical
AppService.IsVerticalView = true;
// show you can return to horizonal
this.currentViewShape = "Horizontal View";
}
// refresh the view
if (this._charsService.AppMode == ApplicationMode.LineBreaker)
{
// reload again
this.router.navigate(['home']);
}
}
The problem is that the component is not "fully" reloading again when re-negativing to the page, how can i reload the page again in order to activate the conditions on templateUrl
and styleUrls
home component?
I have searched a lot but did not found any useful solution, also maybe there is other way to achieve that and my approach is wrong, if there is, please share.