How to view json data from angularjs http callback?

后端 未结 4 401
攒了一身酷
攒了一身酷 2020-12-21 18:26

I can see my json data in the console and I want to view it on html page after clickbutton function. From my understaning I can either do a promise ($q) or then with http o

4条回答
  •  爱一瞬间的悲伤
    2020-12-21 19:30

    I have not worked with promise. But your factory code seems to be ok.

    In controller declare your object first.

    If it's just object declare it as

    $scope.returnedData = {};
    

    If it's array, declare it as

    $scope.returnedData = [];
    

    The the object will not be undefined and changes will affect in HTML

提交回复
热议问题