Pbd
Pbd

Reputation: 1319

callback angular js function in socket

var da="";
var app = angular.module('variantStore', []);
alert("javascript connected");

var socket = io();
$q = 2; //question number

$(document).ready(function(){
    alert("Enter");
    socket.emit('varq',$q);
    alert("qn:"+$q);
});
socket.on('tan',function(da){
        //alert(da);
        window.v=da;
    app.controller('VariantCardDetailsCtrl', ['$scope', function($scope){alert("qw"+v);$scope.variant = da;}]);
});

app.controller is not working, seems like i have issues with making a proper callback.

Upvotes: 0

Views: 199

Answers (1)

maurycy
maurycy

Reputation: 8465

take a look at this article on angularjs and socket.io from HTML5 Rocks

http://www.html5rocks.com/en/tutorials/frameworks/angular-websockets/

i think it will give you pretty good idea how to make things work the proper way

Cheers and good luck

Upvotes: 2

Related Questions