To enhance the functionality of your demo, I suggest moving the HTML into a custom directive:
<div ng-bind-html-unsafe="whatever"></div>
Within the directive, you can dynamically manipulate the HTML content based on specific requirements. To achieve this, you can implement a $watch listener on the 'whatever' variable like so:
$scope.$watch('whatever',function(newValue,oldValue, scope){
//perform necessary actions
});
This code can be encapsulated within the new directive, and it may be beneficial to utilize the postLink function for better organization.
For further information on Angular directives, refer to the official Angular Documentation.
Post-linking function
Executed after the child elements are linked. It is safe to perform DOM manipulations in the post-linking function.