Skip to content

Instantly share code, notes, and snippets.

@stephenlb
Forked from ToeJamson/1.js
Last active December 31, 2015 18:19
Show Gist options
  • Save stephenlb/8025854 to your computer and use it in GitHub Desktop.
Save stephenlb/8025854 to your computer and use it in GitHub Desktop.
<script src="http://cdn.pubnub.com/pubnub.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js"></script>
<script src="http://pubnub.github.io/angular-js/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