<html ng-app="app">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.7.9/angular.min.js">script>
head>
<body>
<div ng-controller="MainController">
<custom-directive>custom-directive>
div>
<script type="text/Javascript">
var app = angular.module("app", []);
app.controller("MainController", function($scope) {
$scope.updateModuleInfo = function(module) {
console.log("module: " + JSON.stringify(module));
}
});
app.directive("customDirective", function($compile) {
return {
template: " {{sampleData}}
",
link: function(scope, element, attrs) {
var module = {
id: "11",
name: "John"
};
scope.module = module;
$compile(element.contents())(scope);
}
};
});
app.directive("rowRenderer", function($compile) {
return {
link: function(scope, element, attrs) {
var link = $compile("");
var childScope = scope.$new();
var node = link(childScope);
childScope.edit = function() {
console.log("Editing row: " + JSON.stringify(scope.aData));
};
element.append(node);
}
};
});
script>
body>
html>