AshBringer AshBringer - 6 months ago 19
AngularJS Question

Angularjs : Apply bold style to a character inside ng-repeat

I have a list :

$scope.list = ["test/test1/test2/test3","test3/test5/test6"];


I would like to apply bold style to
/
characters when displaying the list :

<div ng-repeat="path in list">
<p style="font-weight:bold">{{path}}</p>
</div>


Do you have any ideas how can I achieve this ?

Fiddle

Answer

you can do it simply with str.replace http://jsfiddle.net/k18vgtvw/

 <p style="font-weight:bold" ng-bind-html-unsafe="csc(path)"></p>

controller

  $scope.csc = function(path) {
    return path.replace(/\//g, "<span style='color:red'>/</span>");
  }