如何在angular js表达式中使用xor功能? [英] How to use xor functionality in angular js expression?

查看:63
本文介绍了如何在angular js表达式中使用xor功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

html是

<form name="businessFormAbout" ng-show="(businessFormAbout.$submitted)^(businessForm.$submitted)">

这是第二种形式.默认情况下,此表单将被隐藏,直到提交第一个表单为止.它将再次显示何时提交第一个表格.再次提交第二个(此表单标签)后,它将隐藏.

This is the 2nd form. By default this form will be hidden until the first form is submitted. Again it will show when the first form is submitted. After the second one(this form tag)is submitted again it will hide.

因此,当[1 ^ 0 = 1],[0 ^ 0 = 0]和[1 ^ 1 = 0]时,ng-show将为true.我使用其他逻辑或按位运算符对条件进行了排序.我想知道为什么 xor 运算符在AngularJS中不起作用.

So ng-show will be true when [1^0 = 1], [0^0 = 0] and [1^1 = 0]. I have the condition sorted out using other logical or bitwise operators. I want to know why xor operator is not working in AngularJS.

我想问-AngularJS如何解析或评估传递给指令的表达式(因为ng-show是指令)

I would like to ask - how AngularJS parses or evaluates passed expressions to directives (as ng-show is directive)

[由于这个问题被搁置,所以我无法自己回答这个问题.因此,我正在使用本节中的答案来编辑问题.这是角度文档的问题.他们没有记录这种按位异或的不可用性功能.因此,我在他们的github页面上添加了此问题,并且此问题已落实.]

[As this question is put on hold,I cannot answer to this question myself.So I am editing the question with the answer in this section.This was an issue with angular documentation.They did not documented this unavailability of bitwise xor functionality.So I added this issue on their github page and this was committed.]

推荐答案

您可以改为使用!=模拟异或运算(如果两个值均为boolean,并且在您的情况下为boolean):

You can simulate xor operation by != instead (if both values are boolean, and in your case they are):

<form name="businessFormAbout" ng-show="businessFormAbout.$submitted != businessForm.$submitted">

这篇关于如何在angular js表达式中使用xor功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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