I want to have a single bootstrap 3 alert to show general error or success messages for all the operations a user can perform on a page. The page is divided in different sections with different controllers per section, something like this:
<body ng-app="app">
<div ng-controller="securityController">
[controller methods for change password, validate user section, ...]
<div ng-controller="salesController">
<div class="alert" ng-show="message.visible"><strong>{{message.title}}</strong>{{message.text}}</div></div>
[controller methods for admin sales, admin products, admin retails, ...]
</div>
</div>
</body>
Then I want to be able to bind this html to all the models in the controllers who want to show a message when a user performs an action in the page (Ej. security messages when it interacts with securityController methods, validation messages when it interacts with salesController methods)
First I thought that cascading the controllers and making them have models with the name of the binding variables used in the alert HTML could work (Ej. having a $scope.message object in securityController and in salesController) but it didn't work and I don't really think that is the correct approach.
How can I achieve this?