Michael Michael - 5 months ago 14
AngularJS Question

How can I pass between controllers in same module?

In module named

EventDetails
I have two controllers
attachedFilesList
and
EventDetailsctrl
.

I need to pass string value from
EventDetailsctrl
controller to attachedFilesList controller.

How can I pass between controllers in same module?

Answer

Solution is attached below:

In EventDetailsctrl

$rootScope.$broadcast('pass-value', 'dummyVal');

In attachedFilesList

$scope.$on('pass-value', function(event, value) {
  // value is the object which is passed from $broadcast
});
Comments