How can I replace a string in angular js?
This is what I have tried:
HTML:
<tr ng-attr-id="filter_id(event.kibana._source._id)"></tr>
JS:
$scope.filter_id = function(id){
return id.replace(":","-");
}
But the id won't fill..
How can I replace a string in angular js?
This is what I have tried:
HTML:
<tr ng-attr-id="filter_id(event.kibana._source._id)"></tr>
JS:
$scope.filter_id = function(id){
return id.replace(":","-");
}
But the id won't fill..
Seems you forgot to add the double-braces {{}} around the call:
<tr ng-attr-id="{{filter_id(event.kibana._source._id)}}"></tr>
Here's a Plnkr showing it works. Also note that I changed your filter_id function to use regex for the string replace. As it stands your function would only replace the first occurrence of a :.