JSFiddle - React, Tailwind, and code Playground
by Minko Gechev
HTML
<div ng-app="app" ng-controller="MainCtrl">
<div dir=""></div>
</div>
JavaScript
window.app = angular.module('app', [])
.directive('dir', function ($compile) {
var template = '<input type="text" ng-model="text" /><button ng-click="alertMe()">{{value}}</button>';
return {
compile: function (el) {
el.html(template);
return function (scope) {
$compile(el.html())(scope);
}
}
};
})
.controller('MainCtrl', function ($scope) {
$scope.value = "Alert it!";
$scope.alertMe = function () {
alert($scope.text);
};
});