我正在开发角度js的Web应用程序 我想做一些顺序执行功能。
quoteController.js
(function () {
"use strict";
angular
.module("autoQuote")
//Do initalization on page load
.run(["$log","$rootScope","$state","dtoResource","questionResource",function($log,$rootScope,$state,dtoResource,"questionResource") {
$rootScope.AutoQuote = dtoResource.rc1Step1DTO();
$rootScope.questions = questionResource.getQuestions($rootScope.AutoQuote.postAutoQuoteObj.SessionInfo.StateCode);
console.log($rootScope);
$rootScope.$on("$stateChangeSuccess", function(event, toState, toParams, fromState, fromParams) {
if (fromState.name === "") {
}
});
}])
}());
questionsCtrl.js
(function () {
"use strict";
angular
.module("autoQuote")
.factory("questionResource",["$resource","$http","$state",questionResource]);
function questionResource($resource,$http,$state)
{
return{
getQuestions : function(stateCode) {
var userState = stateCode != "" ? stateCode : 'CA';
$http.get('assets/themes/easyquote/js/questions/'+userState+'.json')
.then(function(response) {
return response.data;
});
}
}
}
}());
在.run我想执行
$rootScope.AutoQuote = dtoResource.rc1Step1DTO();
和$rootScope.questions = $rootScope.questionsCtrl();
当rc1Step1DTO
执行完成并成功时,只应启动questionsCtrl执行。
我无法从.run
执行questionsCtrl函数。是说功能未定义。
请让我知道如何处理角度js中的这种情况。