0

I m actually developping an application with some dashboards with different informations. Actually, I have 6 directives, and each one has his own controller (reusability).

In this application, I manage realtime information transition, and an information received has to refresh each graph, so each directive has to reload.

Question : How can I do without using $scope.$watch or $scope.$observe ?

I dont want to be coupled, so I dont want dependencies between a controller and a directive.

How can I handle that ?

1 Answer 1

1

You can use events. One controller broadcasts an event that the others listen for:

Controller ABC:

$scope.$broadcast("abcEvent", {});

All other controllers:

$scope.$on("abcEvent", function (evt, params) {
    // Do something with the event params from abc
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.