当通过 ng-view 包含时,带有 bootstrap 3 手风琴的 AngularJS 不起作用 [英] AngularJS with bootstrap 3 accordion not working when included via ng-view

查看:25
本文介绍了当通过 ng-view 包含时,带有 bootstrap 3 手风琴的 AngularJS 不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题如下:只要我在 ng-view 指令中加载的视图中使用手风琴,手风琴标题点击就不再正常工作

The problem is the following: As soon as I use the accordion in a view that is loaded in the ng-view directive, the accordion title clicks dont work correctly anymore

http://plnkr.co/edit/KGwuqDIb7I5NrYCtPOPk?p=preview

如果在没有 ng-view 的页面中使用手风琴,手风琴完美运行

If the accordion is use in the page itself with no ng-view, the accordion works perfectly

http://plnkr.co/edit/8dY7JU1kxjZ2jAKmMIrP?p=preview

有什么我遗漏的线索吗?

Any clue to what Im missing?

推荐答案

问题在于 Bootstrap 将 #according_name 附加到 a 标签内.这会触发 AngularJS 路由,并且由于路由更改,每次点击手风琴链接时都会再次加载 test.html.

The problem is that Bootstrap appends #according_name within a a tag. This triggers a AngularJS routing and due to route change test.html is loaded again on every click on accordian link.

您的选择是尝试配置 $locationProvider 以使用带有 hashbag 的 HTML5 模式

Your options are to try to configure $locationProvider to use HTML5 mode with hashbag if it works

$locationProvider.html5Mode(true).hashPrefix('!');

查看一些文档这里

其他将使用 angular-ui 组件,但尚未移植到支持 bootstrap 版本 3.

Other would be to use angular-ui component but it has been not ported to support version 3 of bootstrap.

这篇关于当通过 ng-view 包含时,带有 bootstrap 3 手风琴的 AngularJS 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆