Socket io in angular

I can’t do this example to work.

I have a simple webpage in which I load these scripts at the end:

<script src="./angular.min.js"></script>
<script src="./angular-route.js"></script>
<script src="./socket.js"></script>
<script src="./test.js"></script>

Everything works fine until I load socket.js and add it into my code.

This is the part of my javascript related to modules and controllers:

var modulo_angular = angular.module('app', ['btford.socket-io', 'ngRoute']);
                    //config y defi de las rutas
      $routeProvider.when("/", {
          controller: "appCtrl",
          controllerAs: "vm",
          templateUrl: "home.html"
          .when("/descargas", {
          controller: "appCtrl",
          controllerAs: "vm",
          templateUrl: "descargas.html"
          .when("/opciones", {
          controller: "appCtrl",
          controllerAs: "vm",
          templateUrl: "opciones.html"

modulo_angular.factory('mySocket', function (socketFactory) {
  var mySocket = socketFactory();
  return mySocket;
modulo_angular.factory('factoryController', controladorFactoria);
modulo_angular.controller("navCtrl", ['$http', '$location', controladorPrincipal]);

modulo_angular.controller("appCtrl",['factoryController', 'socket',  controladorSecundario]);

I haven’t included the socket code in my controllers. I just declared the factory and pass as an argument ‘socket’ to my controladorSecundario.

I am getting this error:

Uncaught Error: [$injector:modulerr]$injector/modulerr?p0=app&p1=Error%3A%20…20%20at%20d%20(http%3A%2F%2F10.10.4.121%3A8000%2Fangular.min.js%3A17%3A381)

(anonymous function)    @   angular.min.js:6
(anonymous function)    @   angular.min.js:35
r   @   angular.min.js:7
g   @   angular.min.js:34
ab  @   angular.min.js:38
d   @   angular.min.js:17
uc  @   angular.min.js:18
Jd  @   angular.min.js:17
(anonymous function)    @   angular.min.js:250
a   @   angular.min.js:164
c   @   angular.min.js:32

I don’t know what I have to do, I read on the internet and I have found many people with this problem but I can’t make their solutions to work.

Source: javascript

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.