Angular New Router doesn't load template on page refresh, controller works

352 views Asked by At

I have the following:

function AppController ($router, authService) {
  $router.config ([
      { path: '/', redirectTo: '/home' },
      { path: '/home', components: {'main' : 'home' }},
      { path: '/account', components: {'main' : 'account' }},
      { path: '/campaigns', components: {'main' : 'campaigns' }},
      { path: '/login', components: {'main' : 'login' }}
  ]);
}


angular.module('app.account', ['security'])
   .controller('AccountController', ['authService', AccountController]);


function AccountController (authService) {
    console.log ('this is account controller');
    doCommonController.call(this, authService);
}

//before switching
AccountController.prototype.canActivate = function() {
  return this.authService.isAuthenticated();
}

//before navigation finishes, useful to load required data
AccountController.prototype.activate = function() {
  // return this.testme = true;
  //return this.bigFiles = this.$http.downloadBigFiles();
}

If I click links in menu everything works. If I refresh the page, the template for account.html doesn't load.

The controller loads, it logs inside the console. No other errors generated.

0

There are 0 answers