Skip to content

Instantly share code, notes, and snippets.

@ToeJamson
Forked from anonymous/1.js
Created December 18, 2013 01:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save ToeJamson/8015655 to your computer and use it in GitHub Desktop.
Save ToeJamson/8015655 to your computer and use it in GitHub Desktop.
<script src="http://cdn.pubnub.com/pubnub.min.js"></script>
<script src="components/angular/angular.js"></script>
<script src="scripts/pubnub-angular.js"></script>
<body ng-app="PubNubAngularApp">
<script src="scripts/app.js"></script>
angular.module('PubNubAngularApp', ["pubnub.angular.service"])
<script src="scripts/controllers/main.js"></script>
.controller('JoinCtrl', function($scope, PubNub) { ... });
$scope.publish = function() {
PubNub.ngPublish({
channel: $scope.selectedChannel,
message: $scope.newMessage
});
};
$scope.subscribe = function() {
...
PubNub.ngSubscribe({ channel: theChannel })
...
$rootScope.$on(PubNub.ngMsgEv(theChannel), function(event, payload) {
// payload contains message, channel, env...
console.log('got a message event:', payload);
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment