Try to move replace-directive
down to the <p id="txtProps">
, like this:
<ul class="list">
<li ng-repeat="prop in props" ng-class="cssPropState(prop.state)" ng-click="checkProp(prop)">
<p id="txtProps" replace-directive>{{prop.value}}</p>
</li>
</ul>
Now, the element of the link function is the p element, so the link function would look like:
exo2.directive("replaceDirective", function($timeout){
return function (scope, element, attrs){
$timeout(function() {
var mytext = element.html();
var pattern = /\[(.*?)\]/g;
var results = mytext.match(pattern);
mytext = montext.replace(results[0], "TEST1");
mytext = montext.replace(results[1], "TEST2");
element.html(mytext);
});
}
});