Reputation: 432
.run(['$ionicPlatform', '$rootScope', function($ionicPlatform, $rootScope) {
$ionicPlatform.ready(function() {
var PassData= "Test message Data for List";
$rootScope.$broadcast('dataPassed', PassData);
})
}])
Here in above code broadcast is not getting triggered
In other JS file
$scope.$on('dataPassed', function(event, args) {
$scope.message = args;
console.log('notificationReceived on List : ' + $scope.message);
});
Here in above code we listen for broadcast for getting triggered which is not working here
Upvotes: 0
Views: 394
Reputation: 432
I got the answer as, we can listen to broadcast event which is broadcast from .run method only on .run method of other JS file. like as shown below,
.run(['$rootScope', 'DataSharingService', function($rootScope, DataSharingService) {
$rootScope.$on('notificationReceived', function(event, args) {
$rootScope.message = args;
console.log('notificationReceived on List : ' + $rootScope.message);
});
}]);
from here you can pass data in any services and so on..
Upvotes: 2