Angular: Empty Fiddle
http://angularjs.org/
HTML
<script src="http://code.angularjs.org/angular-1.0.1.js"></script>
<div ng-controller="MyCtrl">
<div ng-click='back()' button='go back!'></div>
</div>
JavaScript
var myApp = angular.module('myApp',[]);
function MyCtrl($scope) {}
angular.module('myApp').directive("button", function () {
return {
template: "<div><div another-directive></div>{{button}}</div>",
replace: true,
scope: true,
compile: function (tElement, tAttrs) {
// this is link function
return function (scope) {
scope.button = tAttrs.button;
};
}
};
});