Using node, express, socket.io, jade and angular. Getting the error: TypeError: Cannot read property 'apply' of undefined
. Any suggestions?
index.js:
module.exports = function(app, res) {
res.render('index', { title: 'Express' });
var io = app.get('io');
io.on('connection', function(socket){
});
};
index.jade:
extends layout
block content
script.
var app = angular.module('hackigur', []);
var socket = io.connect();
var refreshTimer = 10;
app.controller('UpdateController', function($scope){
//socket.on('update', function(msg){
//$scope.refreshTimer = msg;
//$scope.$apply();
//});
setInterval(secondTick,1000);
function secondTick() {
if(refreshTimer != 0) {
refreshTimer -= 1;
}
$scope.refreshTimer = refreshTimer;
$scope.$apply();
};
});
h1= title
p Welcome to #{title}
div(ng-controller="UpdateController")
p(ng-bind="refreshTimer")
layout.jade:
doctype html html(ng-app="hackigur") head title= title script(src = "/socket.io/socket.io.js") script(src = "/js/angular/angular.min.js") body block content
Full error:
Server listening on port 3000 TypeError: Cannot read property 'apply' of undefined at Server.(anonymous function) [as on] (D:\Projects\hackigur\node_modules\so cket.io\lib\index.js:364:15) at module.exports (D:\Projects\hackigur\server\api\index.js:30:8) at ...