$http({
url: '/checkUsername',
data:{name:$scope.username},
method: "POST"
})
.then(function(response) {
$scope.gameStart = true;
})
由于某些原因,$ scope.gameStart不能在then()内,它必须在外面。我的ajax调用完成后,如何在不将代码放入其中的情况下使用$ scope.gameStart?
一些函数代替一堆代码
$http({
url: '/checkUsername',
data:{name:$scope.username},
method: "POST"
})
.then(bunchOfCode)
function bunchOfCode(response) {
console.log('response', response); // still have access to it
$scope.gameStart = true;
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句