Why is ng-non-bindable required for <ui-gmap-windows> element in Angular Google Maps?

僤鯓⒐⒋嵵緔 提交于 2019-12-04 04:12:27

Basically this boils down to ui-gmap doing manual compilation of the template.

In standard angular if you have something like:

<directive>
   <some-html>{{someBinding}}</some-html>
<directive>

That usually means that "directive" is transcluding the content, and therefore "someBinding" is bound to the scope in which "directive" instantiated, not the "directive" innerScope.

However, in the case of ui-gmap:

<ui-gmap-windows>
   <some-html>{{someBinding}}</some-html>
</ui-gmap-windows>

The scope should be to each window that is created, not the scope of ui-gmap-windows instantiation. So if you don't have ng-non-bindable then the scope will be to the ui-gmap-windows instantiation and someBinding will not exist.

Essentially ui-gmap is using the transcluded element as a template for applying to each instantiated window object, but if angular gets in there and binds that element to the wrong scope, then ui-gmap can't rebind to the correct scope.

Hope that clarifies for you a bit.

On a separate note, you really shouldn't use ui-gmap-windows unless you need a number of windows displayed simultaneously. Use a single ui-gmap-window and tie to the active marker.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!