compile:tpload无法在Angularjs app中加载模板

时间:2016-12-05 21:23:31

标签: html angularjs

我的应用程序运行正常,但由于我开始使用$ http服务,我收到[$compile:tpload] Failed to load template错误。我不知道从哪里开始排除故障。我在网上搜索,人们正在谈论在templateUrl字段中添加一个要求但我不明白可以请你帮忙: 这是我的代码:

var myApp = angular.module('myApp', ['ngResource', 'ngRoute', 'ngCookies']);
myApp.value('usersOnline', '');
myApp.value('iden', 'lol');
myApp.config(function ($routeProvider) {
  $routeProvider
    .when('/', {
      templateUrl: 'partials/main.html',
      access: {restricted: true}
    })
    .when('/api/meetups', {
      templateUrl: 'partials/main.html',
      access: {restricted: true}
    })
    .when('/accesscontrol', {
      templateUrl: 'partials/accesscontrol.html',
      access: {restricted: true}
    })
    .when('/login', {
      templateUrl: 'partials/login.html',
      controller: 'loginController',
      access: {restricted: false}
    })
    .when('/prive', {
      templateUrl: 'partials/prive.html',
      controller: 'userController',
      access: {restricted: true}
    })
    .when('/publicforum', {
      templateUrl: 'partials/forumpublic.html',
      controller: 'userController',
      access: {restricted: true}
    })
    .when('/publicforumgw', {
      templateUrl: 'partials/toforumpublic.html',
      controller: 'userController',
      access: {restricted: true}
    })
    .when('/populatedforum', {
      templateUrl: 'partials/populatedforum.html',
      controller: 'userController',
      access: {restricted: true}
    })
    .when('/populatedforumgw', {
      templateUrl: 'partials/toforumpopulated.html',
      controller: 'userController',
      access: {restricted: true}
    })
    .when('/privateforum', {
      templateUrl: 'partials/forumprivate.html',
      controller: 'userController',
      access: {restricted: true}
    })
     .when('/privateforumread', {
      templateUrl: 'partials/forumprivateread.html',
      controller: 'userController',
      access: {restricted: true}
    })
      .when('/privateforumwrite', {
      templateUrl: 'partials/forumprivatewrite.html',
      controller: 'userController',
      access: {restricted: true}
    })
    .when('/privateforumgw', {
      templateUrl: 'partials/toforumprivate.html',
      controller: 'userController',
      access: {restricted: true}
    })
      .when('/messenger', {
      templateUrl: 'partials/messenger.html',
      controller: 'messenger',
      access: {restricted: true}
    })
       .when('/forum', {
      templateUrl: 'partials/forum.html',
      controller: 'messenger',
      access: {restricted: true}
    })
      .when('/messengernew', {
      templateUrl: 'partials/messengernew.html',
      controller: 'messengernew',
      access: {restricted: true}
    })
    .when('/messengergw', {
      templateUrl: 'partials/tomessenger.html',
      controller: 'userController',
      access: {restricted: true}
    })
    .when('/logout', {
      controller: 'logoutController',
      access: {restricted: true}
    })
    .when('/register', {
      templateUrl: 'partials/register.html',
      controller: 'registerController',
      access: {restricted: false}
    })

    .otherwise({
      redirectTo: '/'
    });
});

myApp.run(function ($rootScope, $location, $route, AuthService) {
  $rootScope.$on('$routeChangeStart',
    function (event, next, current) {
      AuthService.getUserStatus()
      .then(function(){
        if (next.access.restricted && !AuthService.isLoggedIn()){
          $location.path('/login');
          $route.reload();
        }
      });
  });
   //$rootScope.test = '';
});

0 个答案:

没有答案