Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Phonegap events on Angularjs controller

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?

like image 482
Daniel Faria Avatar asked Aug 28 '26 16:08

Daniel Faria


1 Answers

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
     });
}]);
like image 75
Michael Tempest Avatar answered Aug 30 '26 13:08

Michael Tempest



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!