We're in the process of creating an app using phonegap onsen and angularJS.
Attempting to invoke a function from a different controller has been challenging. Despite following various documentation such as this
Unfortunately, it's not working for me. Below is the code I've written so far.
module.run(function ($rootScope) {
$rootScope.$on('some-event-here', function (event, data) {
console.log('1');
$rootScope.$emit('show-dialog-of-some-event', data);
//I also tried
//$rootScope.$broadcast('show-dialog-of-some-event', data);
});
});
module.controller('controller1', ['$scope', '$http', function($scope, $http) {
$scope.proceed = function() {
console.log('0');
$scope.$emit('some-event-here', {});
}
}]);
module.controller('controller2', ['$scope', '$http', function($scope, $http) {
$scope.$on('show-dialog-of-some-event', function (event, data) {
console.log('2');
ons.createDialog('some-dialog.html').then(function(dialog) {
//some code here
});
});
}]);
'0' and '1' are displayed on the console but '2' is not showing up.
This seems like a simple issue, yet I can't pinpoint the problem in my code.
Your help is greatly appreciated.