Questions tagged [angular-broadcast]

Angularjs event broadcasting method

Represents the broadcast method provided by to broadcast user defined events. From AngularJS $scope API Reference - $broadcast

Dispatches an event name downwards to all child scopes (and their children) notifying the registered $rootScope/Scope listeners.

45 questions
20
votes
4 answers

Angularjs $broadcast once, $on twice

It sends $broadcast once from the rootScope, but the listener ($on) gets called twice. The listener is in a controller and it uses $rootScope.$on instead of $scope.$on. Has someone had this…
16
votes
3 answers

Call controller function from service in angularjs

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…
7
votes
2 answers

Angular - broadcast , $on called multiple times in directive

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…
5
votes
5 answers

$rootScope.$broadcast not working

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…
Manoz
  • 6,507
  • 13
  • 68
  • 114
3
votes
2 answers

AngularJS: Broadcast event from parent only to it children

I want to broadcast event from parent directive to child. But if I use scope.broadcast in parent directive link function, then all children in every "parent" directive receive it. How it works now: If parent (1) broadcast event, then child (1.1) and…
3
votes
1 answer

Unit testing angularjs directives's event broadcast

I never had to test my angularjs directives before, also the directives I wrote for my current company is uses events to communicated directives to directives and services. And so I wrote a directive, e.g. a search directive. This…
3
votes
3 answers

Custom Angular directive broadcasting an event but not to nested children?

I have created an accordian directive in Angular which can be nested, so an accordian can have child accordians inside them. I want to broadast an event when the accordian opens and closes so that other directives can listen for it (e.g. a menu…
jonhobbs
  • 26,684
  • 35
  • 115
  • 170
2
votes
0 answers

broadcaster action called twice issue in angularjs 4 with ng2-cabel

I m using ng2-cable for chat and broadcast any action from server in rails AngularJs --> In app.component.ts import { Ng2Cable, Broadcaster } from 'ng2-cable'; --> used this for connection private ng2cable:…
Ajay Bhayani
  • 577
  • 4
  • 10
2
votes
0 answers

ModalService $on & $broadcast multiple instances

These are the methods in the same angular controller. The problem is that the $on is called every n clicks. So if it's the 3rd time i clicked to show the popup. The $on will run 3 times and the $broadcast once. I'm trying to kill the $scope, but…
NicoJuicy
  • 3,435
  • 4
  • 40
  • 66
2
votes
0 answers

AngularJS: Communication between dynamically added controllers

This is my first post/question here on StackOverflow so if you see any improvement I can made - please give me an advice :). Now let me dive into the issue. For the sake of simplicity I removed any irrelevant portions of code and presented only…
1
vote
1 answer

how to destroy/unsubscribe broadcast message event in angular2

I am developing application in angular2, here I have used message broadcast for updating data from one component to other. here is code, message_event.ts import {Injectable} from '@angular/core'; import {Observable} from 'rxjs/Observable'; import…
Kishor T
  • 300
  • 1
  • 4
  • 15
1
vote
1 answer

angularjs1.5+ component doesn't receive broadcast event ($on doesn't work)

I was writing some code and realized that angularjs1.5+ component doesn't actually receive the $scope.$broadcast event, means $scope.$on never run in component controller function. Though I was able to $emit the event from the component controller…
anoop
  • 3,812
  • 2
  • 16
  • 28
1
vote
2 answers

angularjs modal service broadcast and on issue

I am using angular-modal-service library. My logic is : when the modal is open it runs a function from SomeService, and $rootScope.$broadcast from SomeService to modal controller that way I can send resource from service to my modal controller.…
Hao Phung
  • 99
  • 1
  • 3
  • 11
1
vote
3 answers

Passign data to directive with $broadcast and Service in AngularJS

I'm in the middle of migrating to Angular based front-end. I have a function in JavaScript to pass some data to directive, after some research found that using Service and $broadcast could be a good solution. but doesn't work for me ... here is my…
Mironline
  • 2,755
  • 7
  • 35
  • 61
1
vote
2 answers

$scope passing has a Delay

I'm building an Angular pop-up system for multiple purposes. The way it works is that I have a directive called bitPopup which three variables get passed on to (type, action and data) as shown below: index.html
1
2 3