我正在使用 angularjs UI-map,我从 firebase 循环数据。到目前为止一切顺利,但是当我单击标记时,它总是显示最后的查询数据。这是狙击手代码
在 html 中
<!-- Setup Marker -->
<div ng-repeat="marker in markers"
ui-map-marker="markers[$index]"
ui-event="{'map-click': 'showMarkerInfo(marker)'}">
</div>
<!-- Setup Marker Info Window -->
<div ui-map-info-window="infoWindow">
<div>Marker - <input ng-model="full_name"></div>
<div>Message</div>
</div>
在 JS 中
firebaseAuth.firebaseRef.child('/human/').on('child_added', function(snapshot) {
$scope.users = snapshot.val();
$scope.latLng = new google.maps.LatLng($scope.users.lat, $scope.users.lng);
$scope.markers.push(new google.maps.Marker({
map: $scope.map,
position: $scope.latLng
}));
});
$scope.showMarkerInfo = function(marker) {
$scope.currentMarkerLat = $scope.users.full_name;
$scope.infoWindow.open($scope.map, marker);
console.log(marker);
};