Reputation: 2785
I'm trying to use ngCordova for my cordova app however, I am getting device
is undefined when calling the below:
var app = angular.module('app', ['ngCordova'])...
app.controller('homeController', function ($scope, $cordovaDevice) {
$scope.pageClass = 'page-home';
$cordovaDevice.getPlatform(); // console.log or something.
});
Everything is included correctly and the plugin is installed. What seems to be the problem?
Upvotes: 1
Views: 169
Reputation: 7244
You need to wait for the deviceready
event before accessing any of the ngCordova plugins
document.addEventListener("deviceready", function () {
$cordovaDevice.getPlatform();
}, false);
Upvotes: 1