I have the following expression wrapped into a scope function to disable the add button in view using angularJS ng-disabled directive :
$scope.disableAddButton = function() {
return (!(currentObjCopy.name || currentObjCopy.name.trim() || currentObjCopy.numAttachments) &&
(mac.input != 'static' || currentObjCopy.name.trim() == '')) ||
!(selectedRow && currentObjCopy) ||
((mac.input != 'random' && !staticMacTemp.length) && !currentObjCopy.startMac));
}
Is there any other alternatives to optimize this expression to pass into ng-disable as follows :
<button type="button" class="px-Button px-Block-Element" ng-click='addLocal()'
ng-disabled="!disableAddButton()">Add</button>
When passing the expressions directly to the directive working fine But passing as a function which results not disabling the button even the expressions are false.
Kindly ignore the Js variables/objects since they could be undefined or null or empty