1
The button should display an Alert but nothing, no error appears. What error? Follow 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>
What exactly are you trying to do?
– André Ribeiro