I am trying to use timer with socket.io in angular js but its not working. I am able to send data from node server to client, also i am getting the alert properly but my timer is not working.
Angular Code
var app = angular.module('MyTimerApp', ['ngRoute', 'timer']);
app.config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/', {
templateUrl: '/index.html'
});
}]);
app.factory('socket', ['$rootScope', function($rootScope) {
var socket = io.connect();
return {
on: function(eventName, callback){
socket.on(eventName, callback);
},
emit: function(eventName, data) {
socket.emit(eventName, data);
}
};
}]);
app.controller('MyController', function($scope, socket) {
socket.on('StartTimer', function(data) {
alert('Starting Timer');
$scope.$broadcast('timer-start');
});
});
I have added below lines in my html code.
<div class="timer">
<h4><timer> minutes, seconds.</timer></h4>
</div>
Also following dependencies added.
<script src="../node_modules/angular-timer/dist/assets/js/angular-timer-bower.js"></script>
<script src="../node_modules/angular-timer/dist/assets/js/angular-timer-all.min.js"></script>
Aucun commentaire:
Enregistrer un commentaire