@nesralla wrote:
Hi everyone !
think its a stupid question...but..
---scenario --
I'm emulate on a chrome browser a ionic app. I have a ng-click and this fire a function to get a current location and put on a list and show on a ng-repeat.My problem is i have to fire a ng-click twice (for first time) to get a first row of location (lat & long). How to solve this !? any exemple !? Maybe is a cache...how the best aproach to do this without any cache...
Thanks in advance sorry for my english !
IgorHere my controller ---
vistoriaApp.controller('VistoriaCtrl', function($scope, $stateParams,$localstorage) { $scope.localizacoes = []; $scope.localiza = {}; var latLong = null; var deferred; /* * if given group is the selected group, deselect it * else, select the given group */ $scope.toggleGroup = function(group) { if ($scope.isGroupShown(group)) { $scope.shownGroup = null; } else { $scope.shownGroup = group; } }; $scope.isGroupShown = function(group) { return $scope.shownGroup === group; }; $scope.getLocalizacao = function () { navigator.geolocation.getCurrentPosition(function(pos) { $scope.localiza.latitude = pos.coords.latitude; $scope.localiza.longitude = pos.coords.longitude; $scope.localizacoes.push($scope.localiza); $scope.localiza = {}; }, function(error) { console.log('Got error!'); console.log(error); $scope.localiza = {}; deferred.reject('Failed to Get Lat Long'); }); } $scope.showAlert = function() { var alertPopup = $ionicPopup.alert({ title: 'Preenche !', template: 'Preenche os dados !' }); alertPopup.then(function(res) { console.log('Log após o fechamento do popup'); }); }; });
Here my html part
<ion-item class="item-accordion" ng-show="isGroupShown(2)"> <ion-item class="item-stable"> Localização </ion-item> <a class="item item-icon-left" ng-click="getLocalizacao()"> <i class="icon ion-location"></i> Capturar Latitude e Longitude </a> <div class="list"> <div class="item item-button-right" ng-repeat="localizacao in localizacoes"> Latitude:{{localizacao.latitude}} <br> Longitude:{{localizacao.longitude}} <button class="button button-assertive"> <i class="icon ion-trash-a"></i> </button> </div> </div> </ion-item> </div>
Posts: 1
Participants: 1