I'm showing a table of data with "ng-repeat", like so:
<table ng-init="mydata=..." ...>
<tr ng-repeat="item in mydata">
<td>{{item['name']}}</td>
</tr>
</table>
I need to replace something in the content of "item['name']" for display.
I try it like so:
<td>{{item['name'].replace(/aaa/gi,'bbb')}}</td>
This way the display in the TD is empty!
When I do a simple replace, it works fine, for example:
<td>{{item['name'].replace('aaa', 'bbb')}}</td>
Is there a problem with the replace function on AngularJS data when using Regex or am I doing something wrong??
I also need this replace for special characters, like apostrophe (" ' ") and quotes ( " )...
I should mention that in this case, I cannot perform the replace anywhere else AND cannot bring the initial data set other than "ng-init" on the table element.
{{...}}. For beter maintenance, I would use filter as @RArun says or single method:{{replaceMe(item['name'])}}