angularjs - variable inside service change value and bind to controller -


using angular have created service

signalr.service("signalrservice", function signalrservice() {  var signalrconfig = {     hub: $.connection.hub,     platformhub: $.connection.platformhub,     tryingtoreconnect: false,     firstconnection: true,     state: 'notconnected' } signalrconfig.hub.url = 'http://localhost:80/signalr'; signalrconfig.hub.logging = true;  var starthub = function ($rootscope) {     settimeout(function () {         $rootscope.$apply(function () {             signalrconfig.state = 'connected';             console.log('jhtfr')         });     }, 5000);  }  return {      starthub: starthub,     getstate: function () {         return signalrconfig.state;     } } 

})

on singalr app, have part of code,

signalr.run(['$rootscope', '$state', '$templatecache', '$http', 'signalrservice', function ($rootscope, $state, $templatecache, $http, signalrservice) {    $rootscope.$state = $state;    signalrservice.starthub($rootscope);}]); 

this signalr app, in web app include dependency, , inside controller call

$scope.signalrstate = signalrservice.getstate() 

i value 'notconnected', after 5 seconds value has not change. how can binding value without use watch , value 'connected'?


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -