Angular-ui-router 和 href='#' [英] Angular-ui-router and href='#'

查看:30
本文介绍了Angular-ui-router 和 href='#'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 angular-ui-router 并且遇到空 a 标签的问题,例如 href='#'.我正在使用引导程序,它广泛使用 href='#' 进行下拉菜单等.问题是,如果用户选择了一个下拉项,那么路由器会将其解释为状态更改,在这种情况下是主页.

I'm using angular-ui-router and have an issue with empty a tags, like href='#'. I'm using bootstrap, which makes extensive use of href='#' for dropdowns and such. The problem is if a user selects a dropdown item then the router interprets that as a state change, which in this case is to the home page.

是否有一种简单的方法可以阻止这种行为,而不必将所有的 href='#' 更改为 href=''.

Is there an easy way to stop this behavior without having to resort to changing all the href='#' to href=''.

推荐答案

只需从锚标记中完全删除 href 标记即可.没有它,它仍然是一个完全有效的标签.

Just remove the href tag completely from your anchor tag. It's still a perfectly valid tag without it.

或者,如果您当前在锚标记中使用 ui-sref,您实际上可以使用 href 属性代替转到状态映射的路线

Or if you're currently using ui-sref in the anchor tag, you could actually use the href attribute instead to go to the route that the state is mapped to.

这篇关于Angular-ui-router 和 href='#'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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