0
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.

2
  • I'd suggest wrapping socket.io into a service and use it inside controller instead of dynamically creating controller on socket.io event Commented Jun 10, 2014 at 10:50
  • I don't know how to create service. Is there any alternative. Commented Jun 10, 2014 at 10:55

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.