0
我想調用一個控制器,當用戶界面加載,但得到低於錯誤。角js錯誤:參數'questionsCtrl'不是函數
angular.js:9778 Error: [ng:areq] Argument 'questionsCtrl' is not a function, got string
http://errors.angularjs.org/1.2.16/ng/areq?p0=questionsCtrl&p1=not%20aNaNunction%2C%20got%string
at http://127.0.0.1:60668/js/angular.js:78:12
at assertArg (http://127.0.0.1:60668/js/angular.js:1443:11)
at assertArgFn (http://127.0.0.1:60668/js/angular.js:1453:3)
at http://127.0.0.1:60668/js/angular.js:7131:9
at http://127.0.0.1:60668/js/angular-ui-router.js:2797:28
at nodeLinkFn (http://127.0.0.1:60668/js/angular.js:6579:13)
at compositeLinkFn (http://127.0.0.1:60668/js/angular.js:5986:15)
at publicLinkFn (http://127.0.0.1:60668/js/angular.js:5891:30)
at updateView (http://127.0.0.1:60668/js/angular-ui-router.js:2733:23)
at http://127.0.0.1:60668/js/angular-ui-router.js:2697:11
我的代碼是:
app.js
(function() {
"use strict";
var app = angular.module("autoQuote",["ui.router"]);
app.config(["$stateProvider","$urlRouterProvider", function($stateProvider,$urlRouterProvider){
$urlRouterProvider.otherwise("/");
$stateProvider
.state("step1", {
url : "/",
templateUrl : "step1.html",
controller: "questionsCtrl"
})
.state("step2", {
url : "/step2",
templateUrl : "step2.html",
controller: "questionsCtrl"
})
}]
);
}());
questionsCtrl.js
(function() {
"use strict";
angular
.module("autoQuote")
.controller("questionsCtrl",["questionsCtrl"]);
function questionsCtrl() {
console.log('here in questionsCtrl');
}
}());
你正確導入'questionsCtrl.js'在HTML頁面中? – Mistalis
是的,js文件包含正確。 –