JSFiddle - React, Tailwind, and code Playground

by Shital Agarwal

HTML

<div ng-app="myApp">
    <div ng-controller="myController">
        <div compile="html"></div>
    </div>
</div>

JavaScript

var app = angular.module('myApp', []);

app.controller('myController', function ($scope, $compile) {
    $scope.callMe = function (book) {
        console.log(book);
        alert("In");
    }
    $scope.book= {
        id:1,
        name:'Best'
    }
    $scope.html = '<div><button ng-click="callMe(book)">clickme</button><div>';
});
app.directive('compile', function ($compile) {
    return function (scope, element, attrs) {
        scope.$watch(

        function (scope) {
            return scope.$eval(attrs.compile);
        },

        function (value) {
            element.html(value);
            $compile(element.contents())(scope);
        });
    };
});