search

Home  >  Q&A  >  body text

jquery - angularjs的数据为什么渲染不到页面上?数据获取到了,我的代码哪里出了错了?

我是用jquery请求数据,想通过angularjs渲染到页面上的.....!

漂亮男人漂亮男人2744 days ago558

reply all(3)I'll reply

  • 世界只因有你

    世界只因有你2017-05-15 17:12:07

    After obtaining the data, apply it to force refresh. I also encountered it a few days ago, and I don't know why. . .

    $scope.weather = responseData.data;
    $scope.$apply();
    

    ================================Supplement================== ===================

    After some research in the past two days, it seems that promises other than angularjs are used to make data requests, and angularjs cannot monitor it. Your code uses $.ajax(), so you need to force a refresh. If you use $http.get() to request data, you should not need $apply to refresh.

    Also, can you send out your API interface? Just what I need!

    reply
    0
  • 仅有的幸福

    仅有的幸福2017-05-15 17:12:07

    http://www.angularjs.cn/A0a6
    You need $apply

    reply
    0
  • 淡淡烟草味

    淡淡烟草味2017-05-15 17:12:07

    You can try this, initialize $scope.weather = {}; at the beginning of the controller function

    reply
    0
  • Cancelreply