Ich versuche, die Funktion im Controller 'Notification' aufzurufen, wenn getNotification in SelectNotificationCtlr aufgerufen wird. Wenn ich das ausführe, erhalte ich einen Fehler, der besagt, dass $ rootScope in der Zeile unter console.log ("log") nicht definiert ist. Ich habe versucht, den $ rootScope als Parameter in meiner getNotification-Funktion übergeben, aber immer noch den gleichen Fehler erhalten.
Bitte beachten Sie meinen Code unten, jeder Rat oder Hilfe würde wirklich geschätzt werden.
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");
}
}
]);
Art
CB
Vielen Dank für die schnelle Antwort. Ich denke, dass es diese frühen Morgenstunden bei der Arbeit sind, die zu mir kommen. Es ist geschätzt. – CBainbridge
Hoffe, es hat geholfen, Ihr Problem zu lösen – Sajeetharan
Ja, funktioniert perfekt. Etwas so einfaches, aber leicht übersehen. Nochmals vielen Dank, der Morgen ist jetzt 100% besser. – CBainbridge