JSFiddle - React, Tailwind, and code Playground
by marco_m_alves
HTML
<script src="http://code.angularjs.org/1.0.0rc5/angular-1.0.0rc5.js"></script>
<script type="text/javascript" src="http://documentcloud.github.com/underscore/underscore.js"></script>
<div ng-app="test">
<div ng-controller="MainCtrl">
<my-directive class="style" arg="John" on-click="onClick">blah</my-directive>
</div>
</div>
CSS
body {font-family: sans-serif; font-size: small;}
JavaScript
var app = angular.module('test', []);
function MainCtrl($scope) {
$scope.count = 0;
$scope.clicks = [];
$scope.onClick = function(argument){
$scope.count++;
$scope.clicks.push({ count: $scope.count, text: argument});
};
}
app.directive('myDirective', function(){
return {
restrict: "E",
template: "<button ng-click='onClick(\"arg\")'>Click me</button>",
replace: true,
scope: {
arg: 'bind',
onClick: 'expression'
}
};
});