我收到错误未捕获错误:缺少参数。您必须指定placeId。。我想,我必须使用$ scope。$ boradcoast和$ scope。$ on来监听这个功能。在service.getDetails中我使用的是placeId,当没有生成这个名为placeId的函数时。但是当我使用硬编码的placeId时,它没有给出错误。所以我的问题是如何处理这种类型的错误?
HTML
<ui-gmap-google-map center='map.center' zoom='map.zoom' control='map.control' id="map-canvas">
<ui-gmap-markers models="markers" idkey="markers.id" coords="'coords'" >
</ui-gmap-markers>
</ui-gmap-google-map>
控制器
function geocodePosition(pos){
geocoder.geocode({
latLng: pos
}, function(responses){
if (responses && responses.length >0){
//Here I am getting place_id, I will use this place Id in PlaceServiec to get details of places.
$scope.place_id=responses[0].place_id;
}
});
var map=$scope.map.control.getGMap();
var service = new google.maps.places.PlacesService(map);
service.getDetails({
placeId: $scope.place_id
//placeId: 'ChIJu5k40vkW0zsReGq7bjOzHxU'
}, function(place, status){
console.log('place='+place);
});
};