【发布时间】:2015-04-30 06:32:12
【问题描述】:
在我的应用程序中,我使用谷歌地图 API v3 来在地图上显示信息窗口。信息窗口充满了$scope 值。地图加载后,$scope 因事件发生变化,但我的信息窗口内容还是一样。
如何让它刷新?
我已经尝试在事件回调函数结束时调用$scope.$apply(),但没有成功。
Controller.js
this.fillingMethod = function(){
info = MyService.getInformation();
$scope.fillingInfo = info;
}
this.changeAnInfo = function(){
var info = $scope.fillingInformation;
var info = MyService.changeInfo(info);
$scope.fillingInformation = info;
$scope.$apply();
}//Google InfoWindow is not refreshed.
View.html
<!-- ng-controller is defined and refers to Controller -->
<map id="map-canvas" center="current-location" zoom="15" ng-init="map.fillingMethod()">
<marker id='test' position="current-location" animation="BOUNCE"></marker>
<info-window id="marker-info" class="gmarker">
<div ng-non-bindable="">
<div id="siteNotice"></div>
<h1 id="firstHeading" class="firstHeading">{{fillingInformation}}</h1>
</div>
</div>
</info-window>
</map>
<button ng-click="changeAnInfo()" />
【问题讨论】:
-
@Noémie O'connor 更新答案,看看它是否适合你:)
标签: javascript angularjs google-maps ionic-framework