3

I generated the skeleton of the app with phonegap-angular-seed and he created a factory with the phonegap event deviceready according to this link. How should I call this event properly on my Angularjs controller?

1 Answer 1

1

So this is just a simple service that returns a callback function for your use once the event has fired.

First you need to add the dependency for the service in your module definition.

var app = angular.module('myApp', ['App.services']);

Then you can inject the cordovaReady into your controller.

app.controller('myController', ['$scope', 'cordovaReady', function($scope, cordovaReady) {
     cordovaReady(function () {
         // Device ready event has fired when this function fires
     });
}]);
Sign up to request clarification or add additional context in comments.

2 Comments

cordovaready is the factory name but how can i call deviceready event on controller??
cordovaReady takes a function as a parameter, this function is called when the device ready event is fired. Look above

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.