这对我有用,这是通过阅读 angular-google-maps 模块问题队列中的一些其他相关错误。
要点是您需要在手表内创建一个变量并使用它传递给模型参数。
基本JS:
controller('MainCtrl', function ($scope, $filter) {
$scope.$watch("breweryFilter", function(breweryFilter){
$scope.filteredMarkers = $filter("filter")($scope.breweries, breweryFilter);
if (!$scope.filteredMarkers){
return;
}
});
});
过滤器输入:
<input name="brewery-filter" class="form-control" type="search" ng-model="breweryFilter" placeholder="filter locations" />
包含标记指令的映射指令:
<google-map
center="map.center"
zoom="map.zoom"
draggable="true"
control="map.control">
<window
show="breweryInfoWindow.showWindow"
coords="breweryInfoWindow.coords"
isIconVisibleOnClick="true"
options="breweryInfoWindow.options"
templateUrl="breweryInfoWindow.templateUrl"
templateParameter="breweryInfoWindow.templateParams"
data-ng-cloak>
_
</window>
<markers
models="filteredMarkers"
idKey="'nid'"
coords="'self'"
icon="'icon'"
doRebuildAll="true"
fit='true'
doCluster='true'
control="map.markersControl"
click="'onMarkerClicked'">
</markers>
</google-map>
希望这对你有帮助。