The button should display an alert but nothing appears, nor an error. What is wrong? Here is the code:
angular.module('App', [])
.directive('sonclick', function () {
return {
restrict: 'A',
link: function(scope,element,attrs){
element.bind('click',function(){
scope.$eval(attrs.sonclick);
})
}
};
})
.controller('CtrlApp', function ($scope) {
$scope.executa = function(){
alert("scope");
};
});
<!DOCTYPE HTML>
<html ng-app="App">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.28/angular.min.js"type="text/javascript"></script>
</head>
<body>
<div ng-controller="CtrlApp">
<button son-click="executa()">clique aqui</button>
</div>
</body>
</html>