Reputation: 463
I was wondering how to use a one way binding on both sides of an equation in the html side of angularjs.
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)].
How can I fix this?
Upvotes: 2
Views: 60
Reputation: 1149
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:
ng-if="::(user.email !== vm.loggedInUser.email)"
or you keep your mental model and use ng-show instead like:
ng-show="::user.email !== ::vm.loggedInUser.email"
Made a plunker to play with, showing the interaction: https://plnkr.co/edit/MPvWVsm4Kkyq9Yq4V0vi?p=preview
Upvotes: 2