ほぼすべてのコントローラーにアラート サービスを挿入することは容易に想像できます。
myApp.factory('AlertsList', function () {
return [{ type: 'info', msg: 'Welcome!'},
{ type: 'success', msg: 'Checkout this subpage'}]
});
/* E.g.: for this controller */
function AlertsCtrl($scope, AlertsList) {
$scope.alerts = AlertsList;
$scope.closeAlert = function (index) {
$scope.alerts.splice(index, 1);
}
}
AlertsCtrl.$inject = ['$scope', 'AlertsList'];
この拡張ボイラープレートを停止するには; このアラート サービスで AngularJS の rootScope を更新するにはどうすればよいですか?