我试图根据来自http请求的响应显示不同的div。
$scope.firstStep = true;
$scope.secondStep = false;
$scope.thirdStep = false;
$http({
method: 'GET',
url: '/api-web/ec/cadastro/recuperar-acesso',
data: {
filiacao: $scope.currentFiliacao,
cnpj: $scope.currentCNPJ
},
headers: {'Content-Type': 'application/json'}
}).then(function(res){
$scope.firstStep === false;
if (res.data.code === -1) {
$timeout(function(){
$scope.secondStep === true; //here is the bug, it dont change to true
console.log("second", $scope.secondStep);
}, 3000)
}
})
我试过几件事情,像$适用(),_defer,从===开关= ...我不知道为什么它的发生。
任何想法?
只要理智,你的代码在if(res.data.code === -1){...}声明中停止,如果你把一个断点正确的话? – zero298
。正确。 – vbotio
只需要提一下'$ scope.firstStep === false;'永远不会设置变量。这是检查价值。 –