JSFiddle - React, Tailwind, and code Playground
by dshilkret
HTML
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular.min.js"></script>
</head>
<body ng-controller="myController">
<div>
<h3>Links</h3>
<a ng-repeat="url in urls" ng-href="{{url}}">{{url}}</a><br ng-repeat-end />
</div>
<div>
<h3>Scripts</h3>
<div ng-repeat="url in scriptUrls">
<script type="text/javascript" src="{{url}}"></script>
</div>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myController', function ($scope) {
$scope.urls = [
'https://www.google.com',
'https://www.example.com',
'https://www.angularjs.org'
];
$scope.scriptUrls = [
'https://example.com/script1.js',
'https://example.com/script2.js',
'https://example.com/script3.js',
'https://example.com/script4.js'
];
});
app.run(function ($rootScope, $timeout) {
$rootScope.$watch(
function () { return document.body.innerHTML; },
function (newVal, oldVal) {
if (newVal !== oldVal) {
$timeout(function () {
// Select all script elements inside the specified div
var scriptElements = document.querySelectorAll('div h3 ~ div > script');
scriptElements.forEach(function (script) {
console.log(script.outerHTML);
});
}, 0);
}
}
);
});
function decodeHTML(encodedStr) {
var parser = new DOMParser();
var doc = parser.parseFromString(encodedStr, 'text/html');
return doc.documentElement.textContent;
}
...