Javascript 如何从angularjs中的$http函数中获取值

Javascript 如何从angularjs中的$http函数中获取值,javascript,php,jquery,angularjs,json,Javascript,Php,Jquery,Angularjs,Json,我已经在angular中创建了一个函数。它工作正常,可以得到正确的结果,但我的问题是我想从结果中得到特定的节点。我曾经使用过JSON和Jquery,但我在angular方面是新手 这是我的密码 $scope.booking= function(docid,addid){ //console.log(addid); var a = $http({ method: 'POST', url: "http://localhost:81/DoctorSta

我已经在angular中创建了一个函数。它工作正常,可以得到正确的结果,但我的问题是我想从结果中得到特定的节点。我曾经使用过JSON和Jquery,但我在angular方面是新手

这是我的密码

$scope.booking= function(docid,addid){
    //console.log(addid);
    var a =  $http({
        method: 'POST',
        url: "http://localhost:81/DoctorStayServiceAngular/model/getDoctorBookingDetail.php",
        params:{"doctorid":docid,"addressid":addid,"day":weekday[d.getDay()]}
        //params:{"doctorid":docid}
    }).then(function mySucces(response) {
        //$scope.count= response.data;
        /*$scope.appo=[];

        $scope.appo= i;
        i++;*/
        //      
        //console.clear();
        return response.data;
    });
    console.log(a);
    return a;
};

返回以下json

{
    "status":"success",
    "message":"",
    "booking":{
        "booking_detail":[{
            "session":null,
            "slot":null,
            "day":"Friday"
        }]
    }
}
这就是我在萤火虫身上看到的

扩展视图

所以我想从响应(在$$状态下)中获取值(我在图中突出显示),我应该怎么做

简而言之,我怎样才能得到最底的结果

{
    "status":"success",
    "message":"",
    "booking":{
        "booking_detail": [{
            "session":null,
            "slot":null,
            "day":"Friday"
        }]
    }
}

$http服务返回一个承诺(打印在控制台日志中),该承诺将在http调用完成后得到解决

请仔细阅读这篇$q文档,了解延迟数据是如何工作的

这应该行得通

$scope.booking= function(docid,addid){
        $http({
                method: 'POST',
                url: "http://localhost:81/DoctorStayServiceAngular/model/getDoctorBookingDetail.php",
                params:{"doctorid":docid,"addressid":addid,"day":weekday[d.getDay()]}
                //params:{"doctorid":docid}
            }).then(function mySucces(response) {
                $scope.responseData = response.data;
            });
        };

在此之后,您可以将responseData中的数据绑定到您的视图。

{“状态”:“成功”,“消息”:“预订”:{“预订详细信息”:[{“会话”:null,“插槽”:null,“日期”:“星期五”}}
此结果中没有
值。如果是打字错误,则回答是
response.value
。结果中没有值,但当我打印控制台日志时,$$状态下有值节点,如图所示。
$scope.result=response
响应。数据
控制台响应一次,结果必须是
{“状态”:“成功”,“消息”:“预订”:{“预订详细信息”:[{“会话”:空,”‌​slot“:null,“day”:“星期五”}]}
a
$http
的承诺。返回函数时需要使用
then()
,如图所示。显示使用此功能的位置