I'm trying to edit a project so that it uses a root view/state, which holds all the other views/states inside it. Before, every page was it's own independent state which wasn't that great when I wanted to add something globally to all states as it would mean you'd have to use $rootScope too often.
So in app.js I've done this:
$stateProvider
  .state('app', {
    url: '/',
    templateUrl: 'app/app.html',
    controller: function($state) {
      $state.go('app.home');
    }
});
So my logic here is that I want to keep the same structure of the website and everything like that. So inside app.html I have just included <div ui-view></div> so that I can inject all the child states, and then on load I am just loading the home state which was originally just the homepage called on '/'.
So now, app.homeis this:
$stateProvider
  .state('app.home', {
    templateUrl: 'app/home/home.html',
    controller: 'HomeCtrl'
  });
No URL here as I'm just loading it from app anyway. And here is another page I've tested:
$stateProvider
  .state('app.test', {
    url: '/test',
    templateUrl: 'app/test/test.html',
    controller: 'TestCtrl',
    authenticate: true
  });
The routing works fine, and the views are loaded, but there are a couple of issues.
- When navigating to - /test, the URL will actually be- http://localhost:4000//testwith two slashes. I can force it to be one slash if I make the url just- testin the- stateProvider, but I don't think that's the correct solution.
- If I reload the page from - /testit will also just redirect me back to- http://localhost:4000/and the root state.
Any ideas?
 
    