Question Background:
I have an Angular app that has 2 views, Using UIRouter I swap in the view that the URL is routed too
Within my views I am using Jasny Bootstrap to produce an off canvas menu 'push' menu, as shown:
https://codepen.io/rugor/pen/eiyzh
This add's a style to the body tag when the menu is revealed as shown:
<body translate="no" class="canvas-slid" style="position: relative; left: 300px; overflow: hidden; right: -300px;">
// Other HTML
</body>
The Issue:
I have the following Index.html View that is used as the main ui-view container for each of my apps pages to be injected in to:
<body ng-app="app">
<div ui-view>
//Views injected here when routed.
</div>
</body
If I browse to my homepage i.e Home.cshtml, I am met with the following page:
body style for the Homepage:
<body ng-app="app" class="ng-scope">
//Homepage Html
I then browse to the Update.html page and reveal the Jansy Off Canvas menu:
Note that the body tag of the Index.cshtml page has had the following style added for the revealing of the off canvas menu:
<body ng-app="app" class="ng-scope canvas-slid" style="position: relative; left: 300px; overflow: hidden; padding-right: 17px; right: -300px;">
</body>
This is where the issue starts.
If I now click the back button on the browser with the Jansy off canvas menu revealed then the body style is not removed from the body tag, as shown:
the body style is still applied:
<body ng-app="app" class="ng-scope canvas-slid" style="position: relative; left: 300px; overflow: hidden; padding-right: 17px; right: -300px;">
</body>
How should I overcome this issue? Can I remove any style on the body tag in the ui-view Index.html when a use user click the back button on their browser? If so how?
I understand why this is happening, and if the user were to close the off canvas menu and clicked back the issue would not occur.
As the body is shared between the Views I need a way of clearing the styling on a back click press to effectively reset it to nothing.