javascript - Calling a controller from another controller in AngularJS -


i have 2 controllers in angularjs app. like:

controller("appctrl", function($scope){      //do stuff here  }) 

and

controller("chatctrl", function($scope, chat_service){      $scope.init = function(){         chat_service.identify(...nick , other data...);         chat_service.on_users_update(function(){...do stuff here...});     }      //some other methods      $scope.init();  }) 

note appctrl main controller , gets executed when open app. problems want call chatctrl.init() appctrl, don't know how.

obviously, $rootscope.$emit() , $rootscope.$on() won't work $on() part (which in chatctrl) hasn't been executed yet @ time ``$emit```` happens.

and don't want chat-related stuff in appctrl.

is there way call init() appctrl?


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -