Is there any potential performance impact of directly binding a function in directives like ng-show in AngularJS?
<div ng-show="myVm.isVisible()">
....
</div>
// controller snippet (exposed through controllerAs syntax)
function myCtrl (myService, authService) {
this.isVisible = function isVisible () {
return (myService.state === 'foo' && authService.isAuthorised);
}
}
This approach allows for concealing complex logic in the template and moving it into the testable controller or service. However, some developers express concerns about binding functions in directives such as ng-show and ng-if.