AngularJS を使用していますが、この問題を解決する方法が見つかりません:
私のコントローラーの一部があります:
$scope.$on('showMoreNotifications', function (event) {
$.ajax({
url: '/notifications',
data: {
notificationCount: 30
},
success: function (e) {
$scope.notifications = e.Messages;
}
});
});
そして、これがこのコントローラーを使用するhtmlです:
<div class="widget" id="widget-notifications" ng-controller="NotificationsCtrl">
<span class="title" ng-click="$parent.$broadcast('showMoreNotifications')">@*showMoreNotifications()*@
Notifikace
</span>
<div class="messages">
<div ng-repeat="item in notifications" class="message-item type-{{item.Entity}}" data-id="{{item.AuditLogId}}">
<span class="type"></span>
<div class="description">
<span class="date">{{item.Date}}</span> / {{item.Message}}
</div>
</div>
</div>
</div>
上部のスパン クラス タイトルをクリックすると、コントローラーがサーバーを正しく呼び出し、JSON データを受信します。残念ながら、それに関連付けられている html を更新しないでください。2 回目にクリックすると、html は最初のリクエストからデータを更新します。