Factory:
factory('cordovaReady', function () { return function (fn) { var queue = []; var impl = function () { queue.push(Array.prototype.slice.call(arguments)); }; document.addEventListener('deviceready', function () { queue.forEach(function (args) { fn.apply(this, args); }); impl = fn; }, false); return function () { return impl.apply(this, arguments); }; }; })
I used this factory in another factory as follows:
return { getCurrentPosition: cordovaReady(function (onSuccess, onError, options) { // } }
The cordovaReady factory function will complete the passed callback when the deviceReady event was fired. My question is: how can I use it in the controller?
I tried only
.controller( 'HomeCtrl', function HomeController($scope, cordovaReady) { cordovaReady(function(){
But that did not work. No console errors. Any ideas?
source share