从角度到直接用户交互使用ng-attr-href [英] Using ng-attr-href from angular to direct user interaction
问题描述
所以我要尝试的是图标(链接),用户将已经登录,并且有一个标识为true或false的属性.根据该属性是true还是false,当用户单击该图标(链接)时,会将其带到2页之一.因此,在angular中查看不同的指令,以为我可以使用ng-switch,但这似乎不可行,所以我认为ng-attr-href可以做到.尝试类似的东西(这是伪代码):
So what I am trying to do is for an icon (link), the user will have already logged on and there is a property identified that is true or false. Based on whether that property is true or false, when the user clicks that icon (link), it will take them to one of 2 pages. So looking at different directives within angular, thought I could use ng-switch, but that doesn't seem viable so I thought ng-attr-href could do it. Trying something like (this is pseudo code):
<a href="somepage.html" ng-attr-href="object.value: false | goto: "otherpage.html""><span></span></a>
因此,这就像if/else,当用户单击图标并且该值为true时,它们将移至一个位置,但是如果为false,则它们将移至其他位置.我的困难在于结构化处理方式以及其他方式/方式.
So this is like an if/else where when user clicks icon and that value true, they go one place, but if false, they go elsewhere. My difficulty is structuring that and how/where the else goes.
是否有比我根据共享对象思考的更好的方法?
Is there a better way to do this than I am thinking based on what I shared?
非常感谢.
加上,这哪里可能是错的?:
Adding to, where could this be wrong?:
<a ng-href="{{ ppt.Globals.value == 'false' '#/claimEnter' : '#/clearSwipe' }}">
<img src="ppt/assets/toolIcons/submiticon.svg" >
<p>Submit a Claim for Reimbursement</p>
</a>
推荐答案
可以在 ng-href
<a ng-href="{{object.value ? 'somepage.html' : 'otherpage.html'}}">
这篇关于从角度到直接用户交互使用ng-attr-href的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!