html - Enable ng-click on a popup (mapbox) -


first apologize poor english

i'm working on map marker , popup declared mapboxgl, i'm trying put ng-click button of popup instantiated in controller

   mymap.on('touchstart', function (e) {         var features = mymap.queryrenderedfeatures(e.point, { layers: ['points'] });             if (!features.length) {                 return;             }             console.log(features);             var feature = features[0];          if(popup == undefined){              var html = '<div class="popup-info">';             html += "<h5>"+ feature.properties.type + "</h5>";             html += "<p>"+ feature.properties.description +"</p>";             html += '<button ng-click="gotocomment()">commentaires (' + nbcomment +') </button>';             html += "</div>";             html += '<a href="#" class="btn-like"><div style="width: 100%">';             html += '<div class="popup-like-img"><img class="icon icons8-thumb-up" src="data:image/png;base64,ivborw0kggoaaaansuheugaaadaaaaawcayaaabxavmhaaaceuleqvroq+1z7xhvmbdcrqbsaaqcsavab1abuagkakifhaogfqavkfraqibqaelgmwvk5sw2bnk+tz5mcjp+86wn3d6t7stesei6d+algkcapgm4jnkdfmz/7ri9sas3ad7s7htj8ij6ng6/ggdoatzpkfyapl0rljuaaetlc5kmvlieapd0ppf/ocjj0loqueisafjyzmx7dybfnz8zjvwm+tccpwdc3crpbmc7jjlfsjpe4ricifn/fwdngdfxljgn1z7kazpwt95hjc/3ekcb9avx3wbztcfjpsabcet+jonsxeu2azd0gmcpgc2ekxr2rijbavh5g5isg70s5gou7j9qtrjyz7fvhpgqguzcus0crbreifffj2j+h4p5/6jpo7tpg0rb09czepeo7ih8xweb7b1a5ieums37nwvbp4svzcw83f2yab6ovvwkwj1wlzjgjhbkq3exaemu502d25d3jf1rdwqjanc6a6gtafiq5nvqaji+axgvocnkpbljcnidktzbugy4dd73sz6spo7/maugaay3xwnasl8nlnnrak5jhuyaozuag9kknqbnjg8ek5yandmg9eusvgbkhwktapc9hc3glqewiefcaw3awautarjml1occogsptuolj3stecbk5khuwqqbqdwpfufpxua2s88sx1zmh64e3np4odewhfcvth2nrg7s5klkt/9d3nl6ixbovoddvvmeib3lir7xd2am/1hy3qqwv0twelunlizwk4kav7key/bgfj3ehbvko7zbtw9pzrpnfhflwxpqaxr0l26mdckmfqvplcp4rxx3qgobeg5/e88mgeh2u//aqzk4zhlkbknaaaaaelftksuqmcc" width="30" height="30"></div>';             html += '<div class="popup-like-nb"><p class ="popup-like-nb-text"> 13 </p></div></div></a>';             /*linkfunction = $compile(angular.element(html));             newscope = $scope.$new();             console.log(linkfunction(newscope));             linkfunction(newscope)*/              popup = new mapboxgl.popup({})                 .setlnglat(feature.geometry.coordinates)                 .sethtml(html)                 .addto(mymap);             }             else {                 popup.remove();                 popup = undefined;             }     }); 

the problem app seems not being able ng-click, looking $compile (comment part right after html declaration) cause think there problem instantiated html in controller, if got idea of how allow ng-click work in instantiated popup.

thx verymuch !

you have compile html $compile. check here

$scope.fn = function () {    alert('clicked');  };   var html = '<button ng-click="fn()">click me</button>';  var compiledhtml = $compile(html)($scope);    var popup = new mapboxgl.popup()   .setlnglat([-91.874, 42.760])  .setdomcontent(compiledhtml[0])   .addto(map); 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -