我在$ scope上有一个对象,它指示应用在更新后的“下一个屏幕”(我处于类似向导的多屏幕新窗体中)并且在显示每个屏幕时,我想显示侧边栏中的当前和所有后续屏幕 - 易于返回供用户进行更改,但不允许他/她通过不显示未来屏幕跳过步骤。
当然,它必须是动态的,因为不同类型的贷款的屏幕顺序会发生变化。
我的问题 - 在当前屏幕的控制器中,如何将状态更改为true,并使视图识别更改? (LoDash是可用的)
这是一个局部$ scope.screens的(对象数组):
[
{
"id": 13,
"loantype_id": 2,
"screen": "farmer",
"label": "Farmer",
"sort_order": 1,
"status": 1
},
{
"id": 14,
"loantype_id": 2,
"screen": "applicant",
"label": "Applicant",
"sort_order": 2,
"status": 0
},
{
"id": 15,
"loantype_id": 2,
"screen": "quests",
"label": "Questions",
"sort_order": 3,
"status": 0
},
{
"id": 16,
"loantype_id": 2,
"screen": "references",
"label": "References",
"sort_order": 4,
"status": 0
}
]
我从农民屏幕移动到屏幕申请人和我可以提醒“申请人“来自状态URL - 该值应该能够用于在$ scope.screens中”查找“正确的对象,但我无法弄清楚它
这是ApplicantController的相关部分 - alert( currScreen)=='申请人':
(function(){
'use strict';
angular
.module('ARM')
.controller('NewApplicantController', function(
$scope, $state, $stateParams, Loan,
AppFactory, ApplicantsFactory
){
var curr = $state.current.url;
var currScreen = curr.substring(1,curr.length);
alert(currScreen);
$scope.loan = Loan.data.data[0];
if($scope.loan.applicant_id) {
ApplicantsFactory.getApplicant($scope.loan.applicant_id)
.then(function success(rsp) {
$scope.applicant = rsp.data.data;
$scope.applicant.entity_type_id = '2';
});
} else {
$scope.applicant = { entity_type_id: '2' };
} // end if
$scope.createApplicant = function() {
ApplicantsFactory.createApplicant($scope.applicant)
.then(function(rsp){
AppFactory.patchIt('/loans/', $stateParams.loanID, {applicant_id: rsp.data.message});
AppFactory.moveToNextNewLoanScreen(currScreen, $stateParams);
});
};
});
})();
究竟在哪里崩溃。 currScreen是未定义的吗? – 2015-02-09 16:02:50
不,currScreen(在这种情况下)提醒'申请人'...我只是不知道如何引用该对象将状态更改为1 ...我试过$ scope.screens [0] .currScreen.status = 1:$ scope。$ apply()但没有工作 – jgravois 2015-02-09 16:13:32