Angularjs ng地图未在信息窗口中显示文本
我有以下代码:Angularjs ng地图未在信息窗口中显示文本,angularjs,google-maps,ng-map,Angularjs,Google Maps,Ng Map,我有以下代码: <ng-map> <marker ng-repeat="item in items" position="{{item[4]}},{{item[5]}}" name="{{item[1]}}" on-click="showInfoWindow('myInfoWindow')"> <info-window id="myInfoWindow"> <h4>{{this.nam
<ng-map>
<marker ng-repeat="item in items" position="{{item[4]}},{{item[5]}}" name="{{item[1]}}" on-click="showInfoWindow('myInfoWindow')">
<info-window id="myInfoWindow">
<h4>{{this.name}}</h4>
</info-window>
</marker>
</ng-map>
{{this.name}}
问题是我看到了信息窗口,但是
h4
中的文本是空的,而不是{{item[1]}}
的内容。您可以这样做
<ng-map>
<span ng-init="name='Test123'">
<marker ng-repeat="item in items" position="{{item[4]}},{{item[5]}}" name="name" on-click="showInfoWindow('myInfoWindow')"></marker>
<info-window id="myInfoWindow">
<h4>{{name}}</h4>
</info-window>
</span>
</ng-map>
{{name}}
info window
指令不得与ng repeat
一起使用,以下示例显示了如何为标记初始化info window的单个实例:
angular.module('ngMap')。controller('MyCtrl',function($scope,ngMap){
NgMap.getMap().then(函数(map){
$scope.map=map;
});
$scope.cities=[
{id:1,姓名:'Oslo',pos:[59.923043,10.752839]},
{id:2,姓名:'斯德哥尔摩',位置:[59.339025,18.065818]},
{id:3,姓名:'Copenhagen',pos:[55.675507,12.574227]},
{id:4,姓名:'柏林',位置:[52.521248,13.399038]},
{id:5,名字:'巴黎',位置:[48.856127,2.346525]}
];
$scope.showCity=功能(事件,城市){
$scope.selectedCity=城市;
$scope.map.showInfoWindow('myInfoWindow',this);
};
});代码>
{{selectedCity.name}
如果名称不是Test123而是item[1],那该怎么办?@gurehbgui让我澄清一件事。信息窗口未包含在标记标记中。因此,您不希望每个标记都有单独的窗口。即使我将其括起来,它也不起作用(更改了问题)hi getting error$scope.map.showInfoWindow不是一个函数