$ injector:modulerr错误

问题描述:

所以我试图学习使用MEAN堆栈的Angular,并且遇到了一个简单的应用程序问题,我正在重新开始工作。

我现在得到的具体错误是angular.js:38 Uncaught Error: [$injector:modulerr],经过几个小时的研究,故障排除和敲打我的头,我似乎无法让我的应用程序再次工作。它在一个非常基本的app.js工作,但我已经改变它使用匿名函数,并调整我的controller.js和factory.js。

下面是我的app.js,factory.js代码,并controller.js

如果有人愿意帮助我的定位是什么问题我会不胜感激!

app.js

(function(){ 
var iquueApp = angular.module('iquueApp', ['ngRoute', 'ngResource', 'iquueApp.iquueCtrl', 'iquueApp.iquueFactory']) 
    .config(function($routeProvider, $locationProvider) { 
$routeProvider 
    .when('/', { 
    templateUrl: '/partials/property-dashboard.html', 
    controller: 'iquueCtrl' 
}).when('/admin', { 
    templateUrl: '/partials/admin-dashboard.html', 
    controller: 'iquueCtrl' 
}).when('/admin/property-setup', { 
    templateUrl: '/partials/admin-prop-setup.html', 
    controller: 'iquueCtrl' 
}).when('/login', { 
    templateUrl: '/auth/login/login.html', 
    controller: 'iquueCtrl' 
}) 
.when('/register', { 
    templateUrl: '/auth/register/register.view.html', 
}).otherwise({ 
    redirectTo: '/' 
    }); 

    // use the HTML5 History API 
$locationProvider.html5Mode(true); 
}); 

})(); 

factory.js

angular.module('iquueApp.iquueFactory',[]) 
.factory('iquueFactory', function($http) { 
    var urlBase = '/api/hubs'; 
    var _iquueService = {}; 

    _iquueService.getHub = function() { 
    return $http.get(urlBase); 
    }; 

    _iquueService.saveHub = function(secretKey) { 
    return $http.post(urlBase, secretKey); 
    }; 

    _iquueService.updateHub = function(secretKey) { 
    return $http.put(urlBase, secretKey); 
    }; 

    _iquueService.deleteHub = function(id) { 
    return $http.delete(urlBase + '/' + id); 
    }; 

    return _iquueService; 
}); 

controller.js

/Angular Controllers 
angular.module('iquueApp.iquueCtrl',[]) 
.controller('iquueCtrl', function($rootScope, $scope, iquueFactory) { 

    $scope.hubs = []; 
    $scope.isEditable = []; 

    // get all hubs on Load 
    iquueFactory.getHub().then(function(data) { 
    $scope.hubs = data.data; 
    }); 

}); 
+0

发布确切的错误@sireken陈述。他应该发表评论 – Ronnie

什么是确切的错误?尝试发布在控制台中看到的确切的错误。这会告诉你什么模块或控制器导致错误..

像这样的......这里MyApp的是哪里出错......

Failed to instantiate module MyApp due to: 
Error: [$injector:unpr] http://errors.angularjs.org/1.3.11/$injector/unpr?p0=e 
at Error (native) 
at  https://ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular.min.js:6:417 
at  https://ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular.min.js:38:307 
at d  (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular.min.js:36:308) 
at Object.e [as invoke]  (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular.min.js:37:64) 
at d  (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular.min.js:35:301) 
at  https://ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular.min.js:35:425 
at s  (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular.min.js:7:302) 
at g  (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular.min.js:35:202) 
at Ob  (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular.min.js:38:435 
+0

嘿感谢您的回复。我其实只是想通了。原来,这个错误是由于JS未被正确加载而导致的。由于输入错误,我错过了angular-resource.min.js文件。 我也没有得到一个详细的错误,但我想这是由于我使用角化的缩小版本? 希望这篇文章能够帮助解决这个问题的其他人! –

+0

我很高兴找到它..干杯 – sireken

感谢您的意见家伙。这个错误是由于没有正确加载angular-resource.js。发布这个问题后不久我解决了它。