var chat = $.connection.tDKTHub;
chat.client.NewNotification = function (notification) {
_notification = JSON.parse(notification);
$scope.Notifications.push(_notification);
console.log($scope.Notifications);
}
<div class="notification-container container">
<br />
<div class="notification row"
ng-class="{unread : notification.STATUS==0}"
ng-repeat="notification in Notifications">
<div class="col-2">
<img style="width:50px;height:50px" />
</div>
<div class="col-10">
<p>{{notification.SENDER_FULLNAME}} {{notification.TYPE_ACTION}} {{notification.MESSAGE}}</p>
</div>
</div>
</div>
即使对象被推入$ scope数组,UI也不会更新。谁知道这里发生了什么? Link to image showing the object was added to the array
答案 0 :(得分:2)
当angular未检测到范围变量中的更改时,您可以通过调用 $scope.$apply();
$scope.Notifications.push(_notification);
$scope.$apply();