【发布时间】:2016-06-12 02:25:32
【问题描述】:
我在模态中使用 ng-map (http://ngmap.github.io/) 在我的应用程序中提供 googlemap,但在该指令出现异常后,页脚中的关闭按钮将不起作用。当我将关闭按钮放在指令之前(例如在标题中)时,它起作用了! 我应该如何捕获此类异常并保持控制?
我的模态如下:
<script type="text/ng-template" id="views/OfficeMapModal.html">
<div class="modal-header">
<div class="modal-title">{{address}}</div>
</div>
<div class="modal-body">
<ng-map zoom="15" center="{{center.latitude}}, {{center.longitude}}">
<marker position="{{center.latitude}}, {{center.longitude}}"></marker>
</ng-map>
</div>
<div class="modal-footer">
<div class="btn btn-default select-again" data-ng-click="cancel()">close</div>
</div>
</script>
我的模态控制器如下:
angular.module('portalApp').controller('GoogleMapModalController', ['$scope', 'NgMap', '$uibModalInstance', 'address', 'center', function ($scope, NgMap, $uibModalInstance, address, center) {
$scope.address = address;
$scope.center = center;
NgMap.getMap().then(function (map) {
google.maps.event.trigger(map, 'resize');
var myLatLng = new google.maps.LatLng(center.latitude, center.longitude);
map.setCenter(myLatLng);
});
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};}]);
编辑:
错误:未定义 google t@http://localhost:3000/bower_components/ngmap/build/scripts/ng-map.min.js:1:2423
【问题讨论】:
-
你能说明你遇到了什么错误吗?
-
发生异常后应用程序无法按预期运行的事实对我来说听起来很正常...您是否尝试过避免或捕获此异常?
-
我编辑了问题并添加了例外。我的问题是我的模态中的 ng-map 指令不是。
标签: javascript angularjs ng-map angular-ui-modal