Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
PubNub Q&A UI w/ Wolfram Alpha API
<!doctype html>
<script src=""></script>
<script src=""></script>
<script src=""></script>
<script src=""></script>
<link rel="stylesheet" href="//" />
<link rel="stylesheet" href="" />
<div class="container" ng-app="PubNubAngularApp" ng-controller="MyQandACtrl">
NOTE: make sure to update the PubNub keys below with your keys,
and ensure that the Q&amp;A BLOCK is configured properly!
<h3>MyApp Questions &amp; Answers</h3>
<input ng-model="toSend" />
<input type="button" ng-click="publish()" value="Send!" />
<br /><br />
<li ng-repeat="message in messages track by $index">
Q: {{message.text}}
<br />
A: {{message.answer}}
angular.module('PubNubAngularApp', ["pubnub.angular.service"])
.controller('MyQandACtrl', function($rootScope, $scope, Pubnub) {
$scope.messages = [];
$ = 'wolfram-channel';
if (!$rootScope.initialized) {
publishKey: 'YOUR_PUB_KEY',
subscribeKey: 'YOUR_SUB_KEY',
$rootScope.initialized = true;
var msgCallback = function(payload) {
$scope.$apply(function() {
$scope.publish = function() {
channel: $,
message: {text:$scope.toSend}
$scope.toSend = "";
Pubnub.subscribe({ channels: [$] });
Pubnub.addListener({ message: msgCallback });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment