Reputation: 49
I use a directive for geolocation input and gives you back the coordinates value in a scope. I want to watch when the scope gets the value so I could do something.
angular.module('app', ['ngAutocomplete'])
.directive('myForm', function() {
return {
restrict: 'E',
templateUrl: 'myForm.html',
};
})
.controller('formCtrl', function ($scope)
{
//watch for details change
$scope.$watch($scope.details, function () {
//alert('details changed')
$scope.formItem.longitude = $scope.details.geometry.location.lng();
$scope.formItem.latitude = $scope.details.geometry.location.lat();
}, true);
});
Upvotes: 0
Views: 34
Reputation: 5273
Change to this,
$scope.$watch('details', function () {
//alert('details changed')
$scope.formItem.longitude = $scope.details.geometry.location.lng();
$scope.formItem.latitude = $scope.details.geometry.location.lat();
}, true);
Upvotes: 1