1
我正在推送數組中的新對象,但無法看到在UI上更新的新值。我在這裏使用角度js並更新一個值。這是我的代碼。列表不更新angularjs中的新對象?
HTML
<ul id="list-wrapper-noti" class="dropdown-menu dropdown-menu-right style-3" >
<div infinite-scroll-disabled = "disableScroll" infinite-scroll='loadMoreNotifications()' infinite-scroll-distance='0' infinite-scroll-container="'#list-wrapper-noti'">
<li >
<a href="list.php?id=20" style=" color:#3C71C1; padding-top: 3px">See all </a>
<a class="pull-right" href="list.php?id=20" style=" color:#3C71C1;">Mark all as read </a>
</li>
<li style="height: 30px"></li>
<li ng-repeat = "notification in notifications track by $index">
<a style="text-decoration:none; color:#534D4D" href="{{notification.href}}" >
<div class="media">
<img src="https://papa.fit/routes/images/inst_logo/default.png" alt="fakeimg" class="img-circle pull-left" style="height:50px; width:50px;">
<div class="media-body">
<div class="media">{{notification.employee}} {{notification.action | lowercase}} {{notification.element}} {{notification.record_value}}</div>
<span class="muted">{{notification.time_string}}</span>
</div>
</div>
</a>
<div class="divider"></div>
</li>
控制器
function addNewNotification(new_noti){
var obj = {"action":new_noti.data.action,"element":new_noti.data.element,"record_value":new_noti.data.record_value,"time_string":new_noti.data.time_string,"employee":new_noti.data.employee};
$scope.notifications.unshift(obj);
console.log($scope.notifications)
}
,從這裏,我呼籲這個FUNC
angular.element('#list-wrapper-noti').scope().addNewNotification(payload);
我不知道爲什麼它沒有得到更新後陣列push.please任何人都幫助?
做日誌(的console.log($ scope.notifications)出現 – Faly
什麼是有效載荷 – Dixit
是@Faly我有了新的OBJ?。陣列並在控制檯上打印。 –