ionic.bundle.js:25642错误:[$ injector:unpr]未知提供程序:$ cordovaGeolocationProvider& lt;-$ cordovaGeolocation& lt-- AgeCtrl [英] ionic.bundle.js:25642 Error: [$injector:unpr] Unknown provider: $cordovaGeolocationProvider <- $cordovaGeolocation <- AgeCtrl

查看:95
本文介绍了ionic.bundle.js:25642错误:[$ injector:unpr]未知提供程序:$ cordovaGeolocationProvider& lt;-$ cordovaGeolocation& lt-- AgeCtrl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正处于通过Ionic构建应用程序的开始阶段.现在,我想在其中实施cordova地理位置.但是,这在打开时始终会给出错误.为了进行测试,我使用了离子服务,并在本地主机中对其进行了检查.

I am currently in the starting phase of building an app via Ionic. Right now i want to implement the cordova geolocation in it. However this keeps giving an error when opening it. For testing purposes i use ionic serve and check it in localhost.

angular.module('starter', ['ionic','ionic.service.core', 'ui.router'])
.controller('AgeCtrl', function ($scope, $state, $http, $cordovaGeolocation) {


$scope.toggleItem = function (item) {
    item.checked = !item.checked;
};

$scope.items = [
  { id: '0-12' },
  { id: '12-18' },
  { id: '18-30' },
  { id: '30-65' },
  { id: '65+' }
];

    $scope.time = Date.now();
   $scope.weather = $http.get("http://api.openweathermap.org/data/2.5/weather?q=Amsterdam&units=metric&APPID=...").then(function(resp) {
   console.log("success", resp);
   }, function(err) {
    console.log("error");
   })

var posOptions = {timeout: 10000, enableHighAccuracy: false};
$cordovaGeolocation
.getCurrentPosition(posOptions)

.then(function (position) {
  var lat  = position.coords.latitude
  var long = position.coords.longitude
  console.log(lat + '   ' + long)
}, function(err) {
  console.log(err)
});

$scope.Confirm = function (){
    $state.go('home');
}
})

我在哪里犯了个错误而导致了这个问题?

Is there any place i have made a mistake which causes this problem?

推荐答案

我认为在离子性中未将其引用为$cordovaGeolocation.尝试使用navigator.geolocation.getCurrentPosition代替吗?

I think it's not referenced as $cordovaGeolocation in ionic. Try navigator.geolocation.getCurrentPosition instead?

这篇关于ionic.bundle.js:25642错误:[$ injector:unpr]未知提供程序:$ cordovaGeolocationProvider& lt;-$ cordovaGeolocation& lt-- AgeCtrl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆