I was wondering how to use a one way binding on both sides of an equation in the html side of angularjs.
我想知道如何在angularjs的html部分的等式两边使用单向绑定。
Example:
例子:
ng-if="::user.email !== ::vm.loggedInUser.email"
I get this parse error
我得到这个解析错误
Error: [$parse:syntax] Syntax Error: Token ':' not a primary expression at column 17 of the expression [user.email !== ::vm.loggedInUser.email] starting at [::vm.loggedInUser.email)].
错误:[$parse:syntax]语法错误:Token ':'不是表达式第17列的主表达式[user]。电子邮件! = =::vm.loggedInUser。电子邮件]从[::vm.loggedInUser.email)]。
How can I fix this?
我该怎么解决这个问题呢?
1 个解决方案
#1
2
So there is two possible fixes to this problem: Either you can change the way of seeing the problem and begin seeing two separate exepressions instead of one. The code would be:
因此,这个问题有两种可能的解决方法:要么改变看待问题的方式,开始看到两个独立的exepresence,而不是一个。的代码是:
ng-if="::(user.email !== vm.loggedInUser.email)"
or you keep your mental model and use ng-show instead like:
或者你保持你的思维模式,使用ng-show来代替:
ng-show="::user.email !== ::vm.loggedInUser.email"
Made a plunker to play with, showing the interaction: https://plnkr.co/edit/MPvWVsm4Kkyq9Yq4V0vi?p=preview
做了一个柱塞来玩,显示了交互:https://plnkr.co/edit/mpvvvsm4kkyq9yq4v0vi?
#1
2
So there is two possible fixes to this problem: Either you can change the way of seeing the problem and begin seeing two separate exepressions instead of one. The code would be:
因此,这个问题有两种可能的解决方法:要么改变看待问题的方式,开始看到两个独立的exepresence,而不是一个。的代码是:
ng-if="::(user.email !== vm.loggedInUser.email)"
or you keep your mental model and use ng-show instead like:
或者你保持你的思维模式,使用ng-show来代替:
ng-show="::user.email !== ::vm.loggedInUser.email"
Made a plunker to play with, showing the interaction: https://plnkr.co/edit/MPvWVsm4Kkyq9Yq4V0vi?p=preview
做了一个柱塞来玩,显示了交互:https://plnkr.co/edit/mpvvvsm4kkyq9yq4v0vi?