我在$ scope上有一个对象,指示" next screen"对于应用程序更新后的更新(我在类似向导的多屏幕新表单中)并且在显示每个屏幕时,我想在侧边栏中显示当前和所有后续屏幕 - 很容易返回用户进行更改但不允许他/她通过不显示未来屏幕来跳过步骤。
当然,它必须是动态的,因为不同类型的贷款的屏幕顺序会发生变化。
我的问题 - 在当前屏幕的控制器中,如何将状态更改为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);
});
};
});
})();
答案 0 :(得分:2)
可能是因为基于您在上面引用的屏幕数组,' currScreen'未定义?我的意思是' $ scope.screens [0] .currScreen'不存在,因此您无法分配' $ scope.screens [0] .currScreen.status = 1'。