角-UI-路由器和HREF =“#” [英] Angular-ui-router and href='#'

查看:119
本文介绍了角-UI-路由器和HREF =“#”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我采用了棱角分明的UI路由器,并与一空的标记,如HREF =#的问题。我使用的引导,这使得大量使用的HREF =的下拉菜单和这样的'#'。的问题是,如果用户选择一个下拉项则路由器间$ P $点,作为一个状态的变化,在这种情况下是到主页

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.

这篇关于角-UI-路由器和HREF =“#”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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