Skip to content

Instantly share code, notes, and snippets.

@mrbaboon
Last active August 29, 2015 14:15
Show Gist options
  • Save mrbaboon/3e18aeb9bab8ea1a1ada to your computer and use it in GitHub Desktop.
Save mrbaboon/3e18aeb9bab8ea1a1ada to your computer and use it in GitHub Desktop.
.directive('newMessageAlert', function(){
return function (scope, element, attrs) {
scope.$watch(attrs.unreadMessageCount, function () {
console.info("newMessageAlert", attrs);
element.stop()
.addClass("unread", {duration: 500})
.removeClass("unread", {duration: 500})
.addClass("unread", {duration: 500})
.removeClass("unread", {duration: 500});
});
}
});
$scope.testNewMessages = function(){
console.info($scope.threads);
angular.forEach($scope.threads, function(thread, index){
$scope.threads[index].unreadMessageCount += 1;
});
};
<a ng-repeat="thread in threads"
new-message-alert="threads[$index].unreadMessageCount"
class="list-group-item thread"
ng-class="{'pending': 'list-group-item-warning', 'active': 'active'}[threadStatus(threads[$index])]"
ng-click="getThreadDetail(thread, $index);">
<div>
<span class="sender">{{ thread.sender }}</span>
<span class="sent-time">{{ thread.created | date:'short':'UTC'}}</span>
</div>
<div>
<span class="thread-subject">
<span class="thread-icon" ng-show="thread.icon_class">
<i class="fa fa-fw text-{{ thread.icon_color }} {{ thread.icon_class }}"></i>
</span>
{{ thread.subject }}
</span>
<span class="thread-subscriber-count pull-right">
<span class="badge badge-primary"><i class="fa fa-group"></i> {{ thread.subscribers.length }}</span>
</span>
</div>
</a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment