2

我正在使用 angular-ui 和 ui-events 模块和 ui-map,但问题是事件绑定不起作用。

HTML

<div id="map" 
     ui-map="myMap"
     ui-options="mapOptions" 
     ui-events="{'map-click': 'addMarker($event)'}"
     class="map-canvas">
</div>

控制器

angular.module('myAppModule', ['ui.map'])
.controller('CtrlGMap', ['$scope', function($scope) {
    $scope.mapOptions = {
        center: new google.maps.LatLng(-54.798112, -68.303375),
        zoom: 11,
        mapTypeId: google.maps.MapTypeId.SATELLITE
    };

    $scope.myMarkers = [];

    $scope.addMarker = function($event) {
        $scope.myMarkers.push(new google.maps.Marker({
            map: $scope.myMap,
            position: $params[0].latLng
        }));
    };

}]);

我知道 ui-map 加载 ui-events 模块。但是当我点击地图时没有任何反应:(

4

1 回答 1

0

对此不是 100% 确定 - 但您可能只能将 $event 与 ng-click 结合使用

于 2014-08-30T19:15:33.457 回答