【发布时间】:2015-07-12 12:18:55
【问题描述】:
我正在使用 Ionic (AngularJS + Cordova)。
使用以下代码,我创建了带有单击事件的标记,但是当我单击标记时,$scope.example 不会在视图中更新(但在控制台中它会显示 id,函数有效)。为什么?
我认为标记不是用 AngularJS(?) 编译的。
$scope.setInfoWindow = function(id){$scope.example = id;console.log(id)}
for(i=0;i<data.length;i++){
marker = new google.maps.Marker({
position: new google.maps.LatLng(data[i].latit,data[i].longi),
map: map,
animation: google.maps.Animation.DROP
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
$scope.setInfoWindow(data[i].id);
}
})(marker, i));
}
【问题讨论】:
标签: angularjs google-maps google-maps-api-3 angularjs-scope google-maps-markers