Update diffrent controller when POST is successful


I have two controllers visible in separate views at the same time.

I need to update view A from view B

For example

When I send POST while viewing get-by-id page and when I watch view A ( list of items ) I want the update of that single post. Can I force the controller to get the information again and update the scope or.

Any thoughts ?


You could use $broadcast to communicate between sibling scopes.

If you have a master scope and two children scopes (one for view A and one for view B), you can do a broadcast from the master scope to inform the children that something happenned, and then in scope A you listen to that particular broadcast.

Example :

Master scope
|- Scope A
|- Scope B

in the B controller, when your envent occurs, you can use :


This will emit a broadcast from the master scope which can be intercepted in the A controller :

$scope.$on(“event”, function())

In there your function() will be the one which updates your A scope.

Angular doc for broadcast

Answered By – CCH

Answer Checked By – Pedro (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.