How do I run a function when socket.io updates a variable. It seems that $watch does not work or purhaps I am doing something wrong.
$http.get('/api/availabilitys/' + myId).then(response => {
  $scope.availability = response.data;
  socket.syncUpdates('availability', $scope.availability);
});
$scope.$watch('availability', function() {
  console.log('test'); //This is not printing on update
  angular.forEach(self.location, function (loc){
    loc.availability = $scope.availability.filter(function (a){
      return a.loc === loc._id;
    });
  });
});
 
     
    