简体   繁体   中英

angular leaflet directive customized popup

I have a question about angular leaflet directive customized popup using compile template. I am using ionic 1.2.4, angular leaflet directive 0.10.0 and leaflet 1.0.0rc-1.

In the controller, I wrote the following code.

var marker = {
            type: markerType,
            lat: myLatlng[0],
            lng: myLatlng[1],
            id: id,
            getMessageScope: function () { return $scope; },
            message: "<a ng-click=\"alert()\">howdy</a>",
            compileMessage: true
        };

        $scope.markersArray.push(marker);


$scope.alert = function(){
            console.log("hahahahaha[");
        }

Here is the fiddle link: http://jsfiddle.net/caiczcz/m7g8Le0L/1/

Although the link is presented in the popup, but the click event is never triggered, I think that the problem might come from the compile process. Any advice is appreciated. THX.

In Angular-leaflet-directive,

 $timeout(function(){
             $compile(marker._popup._contentNode)(markerScope);
           });

this will introduce a flicker issue, which can be resolved by adding a timeout to the popup's showing up or adding some animation, .etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM