我使用指令进行地理位置输入,并返回范围内的坐标值。我想看看范围何时获得价值所以我可以做点什么。
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);
});
答案 0 :(得分:1)
改为此,
$scope.$watch('details', function () {
//alert('details changed')
$scope.formItem.longitude = $scope.details.geometry.location.lng();
$scope.formItem.latitude = $scope.details.geometry.location.lat();
}, true);