1

I am trying to create a chat application and wanted to display availability of users on UI. I am using SignalR and AngularJS.

But UI is not updating after I update members online property like below,

self.hubProxy.client.isAvailable = function (loggedinuser, isOnline) {
      $scope.$apply(function () {
        self.allMembers[loggedinuser].isOnline  = isOnline;
    });

I am using ng-repeat="member in allMembers" to bind with all members and using its isOnline property to apply a class.

Madhu Ranjan
  • 17,334
  • 7
  • 60
  • 69

1 Answers1

0

Assuming your method gets called, and assuming that loggedinuser is the name of the user, then your problem might be with ngRepeat, because you should be enumerating by key:

ng-repeat="(key, value) in allMembers"

Check this: How can I iterate over the keys, value in ng-repeat in angular

Community
  • 1
  • 1
Wasp
  • 3,395
  • 19
  • 37
  • i tried above by having ng-repeat="(key,value) in allMembers" and by using
    Online
    {{value.memberFullName}}
    , full name is being displayed but the div with background being set as green is not displayed even the value is set.
    – Madhu Ranjan Jun 05 '14 at 00:40
  • Thanks for your help, I found the issue it seems ng-show does not reflect changes , when i tried using ng-class="{'isAvailable': value.isOnline, 'isOffline': !value.isOnline}" it worked.. – Madhu Ranjan Jun 05 '14 at 03:05
  • ng-show should definitely reflect changes, glad you solved it anyway – Wasp Jun 05 '14 at 09:45