相关疑难解决方法(0)

在jQuery ajax调用之后,角度控制器范围不会更新

我有这个代码,我无法看到问题的根源在哪里,我没有在我的控制器的chrome控制台中得到任何错误:

function notifController($scope) {
  $scope.refreshMsgs = function () {
    $.post("notification-center-trait.aspx")
      .success(function (data) {
        $("#loadedthings").html(data);
        newMsgs = JSON.parse($("#label1").html());
        $scope.msgs = newMsgs;
      });
  }
  $scope.refreshMsgs();
}
Run Code Online (Sandbox Code Playgroud)

label1label2在div loadingthings内正确加载;

控制台中的newMsgs按其应有的方式进行解析;

我有它在其他页面工作,但似乎我错过了这个上的东西.我有<html ng-app>标签:

<div ng-controller="notifController"> 
    <div class="row">
    {{msgs.length}} new msgs : 
              <table class="table">
                  <tbody >
                      <tr ng-repeat="msg in msgs">
                        <td>
                            {{msg.sender}}
                        </td>
                        <td>
                            {{msg.message}}
                        </td>
                        <td>
                            {{msg.date}}
                        </td>
                      </tr>
                  </tbody>
              </table>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)

当我执行这个时,我在控制台中得到'undefined': angular.element($0).scope()

javascript angularjs angularjs-scope

12
推荐指数
1
解决办法
1万
查看次数

标签 统计

angularjs ×1

angularjs-scope ×1

javascript ×1