1
私はanugularJSの初心者ですので、おそらく私は何か間違っています。私の角度バージョンは1.6.4です。ジオロケーションの場合、私はこのモジュールangularjs-geolocationを使用しています。ここにジオロケーションモジュールplunkerのデモがあります。私のプロジェクトにこのモジュールを組み込み、ブラウザでテストするとこのエラーが出ます。私はすべてのステップを踏んだが、私は何かが足りない。AngularJS:あなたの所在地を特定できません
おそらく未処理の拒絶:あなたの場所
を決定することができません。これは私のユーザーsettings.component.jsファイルです:これは私のユーザーsettings.template.htmlある
(function() {
"use strict";
var module = angular.module(__appName);
function controller($http, geolocation) {
var model = this;
model.location = function() {
console.log("inside");
model.coords = geolocation.getLocation().then(function (data) {
return { lat: data.coords.latitude, long: data.coords.longitude };
});
}
}
module.component("userSettings", {
templateUrl: "components/user-settings/user-settings.template.html",
bindings: {
userId: "<"
},
controllerAs: "model",
controller: ["$http", "geolocation", controller]
});
}());
ファイル:
<div class="text-center">
<button type="button" class="btn btn-default" ng-click="model.location()">Location</button>
{{model.coords}}
</div>
マイApp.jsファイル:
angular.module(__appName, ["geolocation"]);