I\'ve read an article on some AngularJS pitfalls using scopes, and it states that you should not use a function in expressions, and I understand that an expression may be evalua
No, it's not that bad.
Not using functions in expressions would result in HTML bloated with inline javascript.
Consider the elegance of this code:
First name is required!
...
Last name is required!
...
Email is required!
versus this:
First name is required!
...
Last name is required!
...
Email is required!
function Ctrl($scope){
$scope.isInvalid = function(field){
return ($scope.form[field].$dirty || $scope.submitted) && $scope.form[field].$error.required;
};
$scope.submit = function(){
$scope.submitted = true;
// $http.post ...
}
}
Even Angular authors encourage using functions in expressions.
Functions in expressions are welcome in Angular, but with these forethoughts: