I am trying to build a chat with Pusher and AngularJs.
<div id="chats" ng-controller="ChatCtrl">
<chat chat-id="1" chat-name="Max"></chat>
<chat chat-id="2" chat-name="John"></chat>
<chat chat-id="3" chat-name="Susanne"></chat>
</div>
I have the following directive:
.directive('chat', function() {
return {
restrict: 'E',
templateUrl: '/tpl/chat-box.html'
}
}]);
and the following controller:
.controller('ChatCtrl', ['$scope', '$pusher',
function($scope, $pusher) {
$scope.pusher = $pusher(client);
}])
Where should I handle ajax requests to receive old messages and Pusher channel binding to receive new messages for a chat-box? In the controller or in the directive?