- 我有 2 个指令:
wa-hotspots
&wa-tooltips
。 ng-mouseover
其中一个wa-hotspots
采用 $index并 通过匹配索引设置通孔wa-hotspot
的可见性和位置。wa-tooltip
ng-class:on
ng-style="tooltipCoords"
- 注意:由于
wa-hotspots
&wa-tooltips
共享相同的集合page.hotspots
,因此它们通过共享相同的索引ng-repeat
问题:
当您将鼠标悬停在wa-hotspots
它上面时,会将ng-style
位置设置为wa-tooltips
. 我只希望它设置正确的匹配索引。由于可见性由 ng-class 控制,这并不重要,但似乎这是可以避免的额外开销。
所以:
问题:
我怎样才能确保我的 ng-style 不是所有wa-tooltips
on hover 的样式wa-hotspots
?而是仅设置与正确共享索引匹配的工具提示样式?
<ul id="wa-page-{{page.pageindex}}" class="wa-page-inner" ng-mouseleave="pageLeave()">
<li wa-hotspots
<map name="wa-page-hotspot-{{page.pageindex}}">
<area ng-repeat="hotspot in page.hotspots"
class="page-hotspot"
shape="{{hotspot.areashape}}"
coords="{{hotspot.coordinatetag_scaled}}"
ng-mouseover="showTooltip($index, hotspot.coordinatetag_scaled)"
ng-mouseout="hideTooltip()">
</map>
</li>
<li class="tooltip-wrapper">
<ul class="tooltip">
<li wa-tooltips
ng-repeat="hotspot in page.hotspots"
ng-class="{on: hovered.index == $index}"
ng-mouseover="hovered.active == true"
ng-mouseout="hovered.active == false"
ng-style="tooltipCoords" hotspot="hotspot">
</li>
</ul>
</li>
</ul>
工具提示: