-5
無法讀取未定義角JS - >無法讀取屬性
角函數的性質 '結果':
.controller('forgotCtrl', function($scope,$http,$ionicPopup,$state,$ionicHistory) {
$scope.forgot=function(data1){
var link1 = 'http://localhost/uxo_data/forgot.php';
var json10 = {n : data1.mobile };
$http.post(link1, { data1: json10 })
.then(function (res){
$scope.response = res.data1.result;
console.log(res.data1.result);
if($scope.response.created=="1"){
$scope.title="Password Reset!";
$scope.template="Please Check your associated Email Account!";
//no back option
$ionicHistory.nextViewOptions({
disableAnimate: true,
disableBack: true
});
$state.go('login', {}, {location: "replace", reload: true});
}else if($scope.response.exists=="1"){
$scope.title="Failed";
$scope.template="Number you entered doesn't exist";
}else{
$scope.title="Failed";
$scope.template="Contact Our Technical Team";
}
var alertPopup = $ionicPopup.alert({
title: $scope.title,
template: $scope.template
});
});
}
})
輸出I從REST的API得到的是:
{"result":{"created": "0" , "exists": "1" }}
我檢查了Web調試工具,php代碼工作正常,並給出了上述響應作爲輸出。
嘗試的console.log(res.data); –
您的代碼中只有兩個部分試圖訪問*「result」*屬性,並且它們都引用相同的內容。您的第一次檢查應該是您嘗試訪問的對象被正確引用。 'res.data1'是不確定的,那麼你爲什麼認爲可能呢? – Phil