我已经将ionic-framework应用程序集成了angular-google-maps(http://angular-google-maps.org/)。一切工作都非常顺利,但是infoWindow遇到了一些问题。正确,但是info widnow上按钮内的ng-click事件对我不起作用
这是我在控制器中的代码
$scope.confirmCode = function() {
console.log("sdf");
if(confirm("Are you sure?"))
{
Category.getCode(window.localStorage.getItem('user_place'), 0, $stateParams.position_id, $scope.point_id, $scope.currentUser.id, function(data) {
$scope.code = data.data[0];
$scope.pointsModal.show();
});
}
};
这是观点
<div class="map-show col">
<google-map draggable="true" center="map.center" zoom="map.zoom">
<markers models="locations" coords="'self'" icon="'icon'" click="'onClick'">
<windows show="show">
<div ng-non-bindable>{{heading}}<br/>{{address}}<br/><button ng-click="confirmCode()">Redeam</button></div>
</windows>
</markers>
</google-map>
</div>
我想我缺少真正可以对AngularJS进行$ compile的东西,但是由于我是新手,所以我不确定如何使用它。
经过数小时的搜索,点击和试验,Finylyl已经解决了这个问题。下面的帖子很有帮助
https://github.com/angular-ui/angular-google-maps/issues/356#issuecomment-50513058
实际上,问题是infoWindow充当子控制器,而我的功能$ scope.confirmCode()是其父控制器的一部分。所以我做了两件事。
ng-click="$parent.$parent.$parent.confirmCode()"
这是更新的代码
<div class="map-show col">
<google-map draggable="true" center="map.center" zoom="map.zoom">
<markers models="locations" coords="self" icon="icon" click="onClick">
<windows show="'show'" ng-cloak>
<div>{{heading}}<br/>{{address}}<br/><a href="" ng-click="$parent.$parent.$parent.confirmCode()">Redeam</a></div>
</windows>
</markers>
</google-map>
</div>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句