1

In angular-ui-router, the states don't need to have an URL. See this answer.

This works fine when clicking through the UI, however, it seems that back navigation is broken that way:

http://plnkr.co/edit/kr7hyjc1q8i15vcSG9RR?p=preview

app.config(function($stateProvider, $urlRouterProvider, $locationProvider) {
  $locationProvider.html5Mode({
    enabled: true,
    requireBase: false,
  }).hashPrefix('!');

  $stateProvider.state({ 
    name: 'home', 
    controller: function($scope) { }, 
    template: '<h1>home state loaded</h1> ' +
                 '<div ui-view></div>'
  });

  $stateProvider.state({ 
    name: 'home.foo', 
    controller: function() { }, 
    template: '<h1>foo state loaded</h1> ' +
              '<div ui-view></div>'
  });
});

Do some state transitions, then right-click in the window and choose "back" in the context menu. Instead of going back one state, the frame becomes blank.

Is there a way to have states without associated URLs, but with working pushState / history?

Danilo Bargen
  • 18,626
  • 15
  • 91
  • 127

0 Answers0