Angular js ngclick在infowindow中不起作用

时间:2017-11-23 23:36:33

标签: angularjs

我使用Google地图创建了一张地图。首先,当调用init函数时,infowindow是打开的。我从地图中选择了一个位置$ scope.kds正在工作,并且infowindow的内容发生了变化。 infowindow中有一个按钮。当我点击按钮不起作用。我该怎么办?

window.ngApp = angular.module('test', []);
window.ngApp.controller('controllerMap', ['$scope', '$location', '$compile', function ($scope, $location, $compile) {
    $scope.init = function () {
        $scope.latlng = new google.maps.LatLng($scope.lat, $scope.lng);
        $scope.map = new google.maps.Map(document.getElementById('map'), {
            center: $scope.latlng,
            zoom: $scope.zoom,
            minZoom: 6,
            maxZoom: 21
        });

        $scope.marker = new google.maps.Marker({
            map: $scope.map,
            position: $scope.latlng,
            draggable: true,
            icon: 'static/img/pin-4ldpi.png'
        });

        $scope.infowindow = new google.maps.InfoWindow({
            content: "",
            maxWidth: 175
        });
        google.maps.event.addListener($scope.map, 'click', function (event) {
            $scope.kds ();
        });
    $scope.kds = function(){
        $.ajax({
            type: 'post',
            url: "/",
            dataType: 'json',
            async: true,
            cache: false,
            data: {
                mode: "getkds",
                lat: data.response.lat,
                lng: data.response.lng
            },
            success: function (data) {
                if (data.response) {
                    $scope.cityName = data.response.cityName;
                    $scope.contentString = "<div class='text-center fs-16 py-3'>" + $scope.cityName + " <br>\n" +
                        "<a ng-click='runfunc();' class='fs-12 text-red font-sfprodisplay-600 btn btn-color3 btn-sm mt-3'>Analyses</a></div>";
                    $scope.infowindow.setContent($scope.contentString);
                    $scope.infowindow.open($scope.map, $scope.marker);
                    if (!$scope.$$phase) $scope.$apply();
                }
            }
        });

    }

    $scope.runfunc=function(){
        alert("123");
    }

    $scope.init();
}]);

0 个答案:

没有答案