I have html content that should be output by ng-bind-html directive, and after I would like to do some manipulations with this content(for example DOM manipulations, jQuery plugins, etc).
stackoverflow provides me such solution:
<div ng-app="myApp" ng-controller="myCtrl">
<div ng-bind="sometext" my-directive>before</div>
</div>
so to create custom directive with higher priority and watch inside:
angular.module('myApp').directive('myDirective', function() {
return {
priority: 10,
link: function(scope,element,attrs) {
scope.$watch(attrs.ngBind, function(newvalue) {
console.log("element ",element.text());
});
}
};
});
and the Demo
but as far as I'm not going to change this content I don't want to use $watch. Is it possible to do without $watch?