【问题标题】:AngularJS UI-events binding doesn't workAngularJS UI 事件绑定不起作用
【发布时间】:2013-09-12 01:16:31
【问题描述】:

我正在使用 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 模块。但是当我点击地图时没有任何反应:(

【问题讨论】:

    标签: javascript google-maps angularjs


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-05-02
      • 2018-03-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-12
      • 2016-01-16
      相关资源
      最近更新 更多