javascript - Detect page change for one page apps JS -
i'm wondering if has solution tracking "page" changes one-page apps?
i understand concept of one-page app in html/css page preloaded , pages constructed based on dictating elements of page hide/show. though technically it's one-page app, perception of user is several pages/experiences.
what's best way differentiate/track these pages/experiences in one-page app environment?
yes, https://github.com/angular-ui/ui-router has $statechangesuccess
, fired once page/state transition complete. add $rootscope.$on
page controllers want stuff happen on page changes.
http://angular-ui.github.io/ui-router/site/#/api/ui.router.state.$state
$rootscope.$on('$statechangestart', function(event, tostate, toparams, fromstate, fromparams){ console.log('page change happened'); })