我拼命尝试将按钮动态添加到 leaflet.js 标记弹出窗口中并分配回调。然而,我似乎无法理解它。
我正在使用这个例子https://github.com/calendee/ionic-leafletjs-map-demo并将以下行添加到js/controller/mapController.js
中的第105行中
<button class="icon-left ion-information" ng-click="stationInfoButtonClick('+location.name+')"></button>
但是,单击/点击按钮不会调用指定的回调函数。有人有想法吗?
最佳答案
您正在尝试将 HTML 添加到 AngularJS 代码中。这是不可能的。 您需要为此使用 $compileProvider。
在之前版本的传单中,我通过在弹出窗口打开时调用 $compileProvider 来做到这一点。
$scope.$on('leafletDirectiveMap.popupopen', function(event, args) {
var feature = args.leafletEvent.popup.options.feature;
var newScope = scope.$new();
newScope.stream = feature;
$compile(args.leafletEvent.popup._contentNode)(newScope);
});
确实从未在 ionic 上做过,但我对你的返回很感兴趣。
关于javascript - Leaflet.js 将按钮添加到标记弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30197190/