twitter bootstrap popover doesn't work with angularjs

不羁的心 提交于 2019-11-29 09:15:31

I don't see why this question got down-voted. It's a good example on how to understand the principle of scopes in angular. A scope is basically attached to a DOM element. All the controllers, repeats, etc. will only work in this DOM element (the scope). When Boostrap creates a popover, it creates a new DOM element and appends it to body, so now it's out of the scope (it is not in the element any more). That's a key feature to understand about Angular.

Luckily, Bootstrap has the solution. Popover has a container option that lets you append the popover to a specific element instead of body. Put there the jQuery selector of the DOM element that has the angular controller. http://twitter.github.io/bootstrap/javascript.html#popovers (see Options)

At the moment there are at lest 2 projects that got Bootstrap's popover directives for AngularJS written already:

The difference is that http://angular-ui.github.com/bootstrap/ is native AngularJS directives so you don't need any 3rd party JavaScript dependencies.

Both projects are hosted on GitHub so you can see implementations and either learn from them, decide to change or just use one of the projects.

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