Angular New Router在页面刷新时不加载模板,控制器工作

时间:2015-05-19 09:02:14

标签: angularjs angularjs-new-router

我有以下内容:

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();
}

如果我点击菜单中的链接,一切正常。如果我刷新页面,则不会加载account.html的模板。

控制器加载,它在控制台内登录。没有产生其他错误。

0 个答案:

没有答案