var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope, $compile) {
});
app.directive('pageContents', function($compile){
return {
link: function(scope, element, attrs){
var html = '<a href="http://localhost/about-us/">About Us</a> <a href="http://localhost/contact/">Contact</a>';
var matches = html.match(/href="(.+?)"/g);
matches.forEach(function(href){
var url = href.match(/href="(.+?)"/)[1]
html = html.replace(href, 'ng-click="loadPage(\''+url+'\')"')
});
var pageEl = $compile(html)(scope);
element.append(pageEl);
scope.loadPage = function(url){
scope.clicked = 'clicked ' +url;
};
}
};
});
<!DOCTYPE html>
<html ng-app="plunker">
<head>
<meta charset="utf-8" />
<title>AngularJS Plunker</title>
<script>document.write('<base href="' + document.location + '" />');</script>
<link rel="stylesheet" href="style.css" />
<script data-require="angular.js@1.0.x" src="http://code.angularjs.org/1.0.7/angular.min.js" data-semver="1.0.7"></script>
<script src="app.js"></script>
</head>
<body ng-controller="MainCtrl">
<div page-contents></div>
<p>{{clicked}}</p>
</body>
</html>
/* Put your css in here */