I am facing an issue while trying to call the function inside the controller 'Notification' when getNotification is executed in the SelectNotificationCtlr. The error message indicates that $rootScope is undefined just below the line console.log("log");. I attempted to pass $rootScope as a parameter in my getNotification function, but the error persists.
If you could please review my code below and provide any advice or assistance, I would greatly appreciate it.
app.js
selectNotification.controller('selectNotificationCtlr', ['$scope', '$rootScope', 'notificationsService',
function($scope, $http, notificationsService, notificationService, $rootScope) {
$scope.getNotification = function() {
var id = $scope.selectedNotification;
notificationData = notificationsService.getNotifications();
console.log(notificationData);
console.log("log");
$rootScope.$emit("call", {});
}
}
]);
selectNotification.controller('Notification', ['$scope', '$rootScope',
function($scope, $rootScope) {
$rootScope.$on("call", function() {
$scope.parent(notificationService);
});
$scope.parent = function() {
console.log("log");
}
}
]);
Best regards
CB