To work with sticky states, you do not have to destroy the DOM element. If you look at your state structure, you use the named ui-view body for the home state, according to the ui-router-extras documentation. However, you then clobber this ui-view element when you transition to the about state, which also uses the body ui-view. This can be observed by checking the DOM.
.state('home', { url: "", deepStateRedirect: true, sticky: true, views: { "body": { templateUrl: 'templates/home.html' }, " event_list@home ": { sticky: true, templateUrl: "templates/eventList.html", controller: "eventListCtrl" } } }) .state('about', { url: 'about', views: { "body": {
Ensure that the ui-sticky state is not reused. For your example, put about status in an unnamed representation.
.state('about', { url: 'about', templateUrl: 'templates/about.html' });
index.html
<div ui-view="body" ng-show="$state.includes('home')"></div> <div ui-view></div>
JS:
app.run(function($rootScope, $state) { $rootScope.$state = $state } );
source share