ng-click to call a function in scope
Description
The following code shows how to use ng-click to call a function in scope.
Example
<!DOCTYPE html>
<html ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
<script type='text/javascript'>
<!-- w w w .j ava 2 s .c o m-->
function Ctrl1($scope) {
$scope.test = function(callback){
eval(callback);
};
}
</script>
</head>
<body>
<div ng-app="">
<div ng-controller="Ctrl1">
<button ng-click="test('console.log(\'pushed\');')">Push Me</button>
</div>
</div>
</body>
</html>