2

In my templates i've got a lot of conditions related to my user rights and products rights, for example:

<div ng-if="user.rights == 'admin'  || user.rights == 'owner'  || products.rights.technical"></div>

Thoses rights can't be changed without going to a new page... so I was thinking that I could use one-binding :: for better performance.

I tried:

<div ng-if="::(user.rights == 'admin'  || user.rights == 'owner'  || products.rights.technical)"></div>

and also:

<div ng-if="::user.rights == 'admin'  || ::user.rights == 'owner'  || ::products.rights.technical"></div>

but the condition doesn't seems to work, any idea ?

user2283958
  • 105
  • 2
  • 8

1 Answers1

1

Probably, compute user.rights == 'admin' || user.rights == 'owner' || products.rights.technical at page load and assign it to another scope variable (say $scope.isOwnerOrAdmin). And then, use one way binding to bind this variable to ng-if. like: ng-if="::$scope.isOwnerOrAdmin".

Sachet Gupta
  • 777
  • 4
  • 17
  • humm you might be right but i've got a lot of differents possibilities, depending on the page i'm not checking for the same right – user2283958 Apr 12 '17 at 10:58