I have a unique situation where I need to monitor and recompile the entire DOM of a page whenever it undergoes any changes. While AngularJS handles this through databindings, I require a solution that goes beyond just bindings. My app is constructed using HTML, Javascript, and PHP in a single-page application format, with PHP injected into a DIV wrapper within the main page.
I am looking to make alterations to the code while keeping it distinct from the original. To achieve this, I must recompile the DOM every time a new PHP file, each with its own DOM structure, is added. However, my current approach seems unable to accomplish this task.
app.directive("watch", function () {
return function (scope, element, attr) {
scope.$watch("watch", function(oldValue, newValue) {
if(newValue) {
console.log("there is a new value");
console.log("the new value is " + newValue);
}
});
}
});
I have included the watch attribute to the <body>
tag, but unfortunately, it does not seem to be functioning as desired. There are no logs generated when the DOM is altered. Ultimately, I aim to replace the console.log with $compile, but I am currently focusing on getting the watch functionality to work properly. Can anyone offer guidance on where I may be making errors in my implementation?