I would like to extend some module with UI-logic.
For example - simple modul, who can add alerts and clear alerts. And use it in other modules.
var MessageBox = angular.module('MessageBox', ['ui.bootstrap']);
MessageBox.controller('MessageBoxController', ['$rootScope', function ($rootScope) {
$rootScope.alerts = [];
$rootScope.addAlert = function (alert) {
$rootScope.alerts.push(alert);
};
$rootScope.closeAlert = function (index) {
$rootScope.alerts.splice(index, 1);
};
}]);
End Using in another module:
var App = angular.module('App', ['MessageBox']);
... and controller:
console.log("$scope.alerts : " + $scope.alerts);
addAlert({type: 'success', msg: 'Message.'});
Is it best practices for extending modules and functions?
P.S. please rank this question, I can't get 15 reputation. Thanks!