Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 使用http.post结果数据的IonicPopUp_Angularjs_Ionic Framework - Fatal编程技术网

Angularjs 使用http.post结果数据的IonicPopUp

Angularjs 使用http.post结果数据的IonicPopUp,angularjs,ionic-framework,Angularjs,Ionic Framework,如何将数据从http.post结果传递到IonicPopUp 在我的http.post成功部分中,我创建了alertPopUp函数,并将结果作为参数传递 它会打开弹出窗口,但没有数据显示 我想显示$scope.result中的任何数据 下面是我使用$ionicPopup/中的示例的代码: `$scope.showAlert = function(result) { var alertPopup = $ionicPopup.alert({ title: 'Detais', t

如何将数据从http.post结果传递到IonicPopUp

在我的http.post成功部分中,我创建了alertPopUp函数,并将结果作为参数传递

它会打开弹出窗口,但没有数据显示

我想显示$scope.result中的任何数据

下面是我使用$ionicPopup/中的示例的代码:

`$scope.showAlert = function(result) {

 var alertPopup = $ionicPopup.alert({

    title: 'Detais',
    template: 'Details : 1. {{result}} 2. {{state}} {{result.vehicle_brand}} 2. {{scope}}'
 });
 alertPopup.then(function(res) {
     console.log('Thank you for not eating my delicious ice cream cone');
 });
};`

这可能是当您收到
结果
对象时对象的属性访问问题

从$http.post成功回调函数中尝试以下代码。尝试打印出该结果的结构,如以下代码段所示:

$http.post(url).then(function(result){
    console.log(JSON.stringify(result, null, 2));
});
我认为它的结构可能是这样的:

{
  "data": //Your result should be available here!
       { "vehicle_brand": { "a": "b" } },       
  "status": 200,
  "config": { 
      "method": "POST",
      ...
  }
  "statusText": "OK" } 
}
$http.post(url).then(function(result){
    console.log(JSON.stringify(result, null, 2));
    $scope.showAlert(result.data); //Pass the data property as a argument.
});
然后您可以将其传递给您的ionic弹出函数,如下所示:

{
  "data": //Your result should be available here!
       { "vehicle_brand": { "a": "b" } },       
  "status": 200,
  "config": { 
      "method": "POST",
      ...
  }
  "statusText": "OK" } 
}
$http.post(url).then(function(result){
    console.log(JSON.stringify(result, null, 2));
    $scope.showAlert(result.data); //Pass the data property as a argument.
});