2017-12-15 8 views
1
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

答えて

2

スコープ変数の変化を検出しない場合、角度、手動$scope.$apply();

$scope.Notifications.push(_notification); 
$scope.$apply(); 
+0

に呼び出すことによって変更をバインドすることができますが、これは全体の朝、私を悩ませてきた、ありがとうございました。 –

+0

今は大丈夫です。ありがとう – lancha90

関連する問題