Call scope function in expression
Description
The following code shows how to call scope function in expression.
Example
<!DOCTYPE html>
<html ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
</head><!--from www .j av a2 s . co m-->
<body>
<div ng-app="myApp" ng-controller="main">
{{render(true)}}
<br/>
{{render(false)}}
</div>
<script type='text/javascript'>
angular.module("myApp", []);
function main($scope) {
$scope.render = function(condition) {
return condition ? "This is rendered when condition == TRUE" : "This is rendered when condition == FALSE";
};
}
</script>
</body>
</html>