ng-repeat没有填充<info-window> </info-window>

时间:2014-10-25 12:57:16

标签: javascript angularjs google-maps google-maps-api-3 angularjs-directive

我在我的应用程序中使用angularjs-google-maps指令,它一直工作到现在为止。

我想在Item中显示Shop <info-window>ng-repeat。但是,<map> <div ng-repeat="shop in shops"> <marker id="{{shop.shop_name}}" position="{{shop.position}}" title="{{shop.shop_name}}" on-click="showInfoWindow(event, shop.id)"></marker> <info-window id="{{shop.id}}" visible-on-marker="{{$index}}"> <div style="width: 500px; height: 300px;"> {{ shop.shop_name }} <br /> {{ shop.items[0].name }} <!-- This line is not working --> <div ng-repeat="item in shop.items">{{$index}}|{{item.name}}</div> <div class="clear"></div> </div> </info-window> </div> </map> 没有填补,我无法理解为什么。

ng-repeat

<info-window>为什么{{1}}没有填充数据?

1 个答案:

答案 0 :(得分:0)

您的代码没有明显的错误,因为

$scope.shops = [{
  id: 1,
  name: 'name1',
  items: [1,2]
},{
  id: 2,
  name: 'name2',
  items:[3,4,5]
}];

然后是HTML模板

<div ng-controller="" class="ng-scope">
  <map center="" zoom="">
    <info-window id="1" position="">
      <div ng-non-bindable="">
        <div ng-repeat="shop in shops">
          <div>
            shop id:{{ shop.id }} name:{{shop.name}}
          </div>
          <div ng-repeat="item in shop.items">
            item:{{ item }}
          </div>
        </div>
      </div>
    </info-window>
  </map>
</div>

给你

imgur

此处相关的plunker http://plnkr.co/edit/kJvhCX