angular-broadcast

$rootScope.$broadcast not working

ε祈祈猫儿з 提交于 2019-12-10 15:28:02
问题 I am trying to get $rootScope.$broadcast to refresh my view. The service is- var app = angular.module("productsApp", []) .service("serviceProvider", function ($http) { this.getDatas = function getDatas(data) { return $http({ method: 'POST', url: serviceUrl + '/GetProductsByCategoryOrName', headers: { 'Authorization': apiKey }, data: data }) } return this }).factory("sharedService", function ($rootScope) { var mySharedService = {}; mySharedService.values = []; mySharedService.passData =

Angular - broadcast , $on called multiple times in directive

半城伤御伤魂 提交于 2019-12-08 19:47:39
问题 I am working on a single page app, with angular and I have a need to communicate between 2 different directives which basically don't have a parent child relation. In Directive A, I have 2 places where I need to broadcast same event from different functions. And in Directive B, have written a $on listener for that. Now, I observe that the whenever callFirstFunc & its broadcast is called for first time, the listener will be called once. Upon subsequent calling, the listener is called twice,

Call controller function from service in angularjs

无人久伴 提交于 2019-11-30 08:51:52
I am using socket.io to enable chat in my app and i am using a service SocketService to perform all the socket stuff. When a message came then i want to trigger a function of a controller from the service SocketService to make some changes in the UI. So i want to know that how can i access the function of a controller from the service. Sample Code: .service('SocketService', function ($http,$rootScope,$q) { this.connect = function(){ var socket = io(); socket.on('connect',function(){ // Call a function named 'someFunction' in controller 'ChatController' }); } }); This is the sample code for

Call controller function from service in angularjs

谁都会走 提交于 2019-11-29 12:17:16
问题 I am using socket.io to enable chat in my app and i am using a service SocketService to perform all the socket stuff. When a message came then i want to trigger a function of a controller from the service SocketService to make some changes in the UI. So i want to know that how can i access the function of a controller from the service. Sample Code: .service('SocketService', function ($http,$rootScope,$q) { this.connect = function(){ var socket = io(); socket.on('connect',function(){ // Call a