<!DOCTYPE html>
<html data-ng-app="chartTest">
<head>
<script data-require="angular.js@1.3.14" data-semver="1.3.14" src="https://code.angularjs.org/1.3.14/angular.js"></script>
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>
</head>
<body data-ng-controller="chartController">
<div class="customChartsDiv">
<div custom-charts dashboard1-data="dashboard1Data" title1-text="title1Text" dashboard2-data="dashboard2Data" title2-text="title2Text" template="template"></div>
</div>
</body>
</html>
// Code goes here
var app = angular.module('chartTest', []);
app.controller('chartController', ['$scope', function($scope) {
$scope.template = '<div>test</div>';
}]);
app.directive('customCharts', ['$compile', function($compile) {
return {
restrict: 'EA',
scope: {
dashboard1Data: '=',
title1Text: '=',
dashboard2Data: '=',
title2Text: '=',
template: '='
},
link: function(scope, element, attrs) {
var parent = angular.element(document.querySelectorAll('.customChartsDiv')) // DOM element where the compiled template can be appended
var linkFn = $compile(scope.template);
var content = linkFn(scope);
parent.append(content);
}
}
}]);
/* Styles go here */