I have this controller that sends a normal Error or Success notification
$scope.add = function () {
if(!$scope.name || !$scope.url ){
$scope.success = null;
return $scope.error = 'Preencha todos os campos.'
}else{
var newGroup = {
name: $scope.name,
url: $scope.url
}
$http.post("/api/group/add", newGroup).then(function (response) {
if(response.data.err){
$scope.error = response.data.err;
$scope.success = null;
}else{
getGroupByAccess();
clearForm();
userSessionService.updateUserMenu();
$scope.success = response.data.msg;
$scope.error = null;
}
});
}
}
And I have this controller that sends a more organized notification
var notifyApp = angular.module('notifyApp',['angular-growl','ngAnimate']);
notifyApp.controller('notifyCtrl',['$scope','growl',function($scope,growl){
$scope.showError = function(){
growl.error('This is a error mesage.',{title: 'Error!'});
}
$scope.showSuccess = function(){
growl.success('This is a success mesage.',{title: 'Success!'});
}
}]);
And this is the call
.content(ng-controller="groupsController")
.alert.alert-danger(ng-show='error' class='ng-hide')
span{{error}}
button.close(type='button', aria-label='Close' data-toggle='tooltip' data-placement='top' title='Close' ng-click='close()') x
.alert.alert-success(ng-show='success' class='ng-hide')
span{{success}}
button.close(type='button', aria-label='Close' data-toggle='tooltip' data-placement='top' title='Close' ng-click='close()') x
How can I use this second controller in the first one, remembering that everything is importing and working, I just need to understand how it would be done and called