angularjsone-time-binding

is mixing one time with one way binding in Angualrjs possible inside ng-if?


I'm using latest AngluarJS release, I was wondering if I can combine one time with one way binding in one expression inside ng-if directive , some like that:

ng-if="(vm.isUnix) && (::vm.isGnsEnabled)"

The line above throws an error, not working


Solution

  • This is not possible. The one time binding token must come first and will mean that once the expression is stable it will no longer be watched.

    ng-if="::vm.isUnix && vm.isGnsEnabled"
    

    If vm.isUnix can change during the lifetime of your component and you need to reflect this change in the view, there is no way to prevent a watcher for this expression.

    Edit: basically one-time binding is for the entire expression, not for individual properties inside the expression.