AngularJS directive Example
HTML
<div ng-controller='myctrl'>
<LoadingButton> </LoadingButton>
<button ng-click="clickMe()">call clickMe()</button>
<div>
CSS
.ng-scope{
border: 1px red solid;
}
JavaScript
angular.module('components', []).
angular.module('myApp', ['components']).controller('myctrl', ['$scope', function($scope) {
myApp.directive('LoadingButton', function() {
return {
restrict: 'E',
replace: true,
template: '<span> abc </span>',
link: function($scope, element, attrs) {
$scope.clickMe= function() {
alert('inside click');
}
}
}
});
}]);