我無法得到以下的工作,我不斷收到Unknown provider
錯誤。有任何想法嗎?
var app = angular.module('app', ['ui.router']);
app.config(function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise("/");
$stateProvider
.state("home", {
url : "/",
templateUrl : "resources/static/views/home.html",
controller: "HomeCtrl",
controllerAs: "homeCtrl"
}
);
});
app.controller("HomeCtrl", ["$scope", function ($scope) {
var _this = this;
// do stuff
}]);
完全錯誤:
angular.1.5.8.min.js:118 Error: [$injector:unpr] http://errors.angularjs.org/1.5.8/$injector/unpr?p0=<div ui-view="" class="ng-scope">copeProvider%20%3C-%20%24scope%20%3C-%20HomeCtrl
at Error (native)
at http://localhost:8080/resources/scripts/js/include/angular.1.5.8.min.js:6:412
at http://localhost:8080/resources/scripts/js/include/angular.1.5.8.min.js:43:174
at Object.d [as get] (http://localhost:8080/resources/scripts/js/include/angular.1.5.8.min.js:40:432)
at http://localhost:8080/resources/scripts/js/include/angular.1.5.8.min.js:43:236
at d (http://localhost:8080/resources/scripts/js/include/angular.1.5.8.min.js:40:432)
at e (http://localhost:8080/resources/scripts/js/include/angular.1.5.8.min.js:41:158)
at Object.instantiate (http://localhost:8080/resources/scripts/js/include/angular.1.5.8.min.js:42:24)
at http://localhost:8080/resources/scripts/js/include/angular.1.5.8.min.js:90:32
at Object.<anonymous> (http://localhost:8080/resources/scripts/js/include/angular-ui-router.0.3.1.min.js:7:23872)
而且link
和HTML
<div>Home</div>
爲清楚起見,我需要使用controllerAs,所以刪除它是不是一種選擇。
編輯:必須是ui.router 0.3.1版本中的一個錯誤,當我切換到0.3.2時它工作正常。
發佈完整的錯誤和HTML – Sajeetharan
中的編輯 – holtc
HTML代碼中添加你的 – Sajeetharan