Help with a global replace on a string in a directive
ng-change="Title1=dashboardchartType.replace('X', 'Y ');" This works for the first instance .. does anyone know how to do same as global replace or even a multiple replacement? I must be missing something cause I've tried every combination of .replace(/'X'/g, 'Y') ('/X/g', 'Y') etc. also .replace('W' | 'X', 'Y') does not evaluate.
Thanks in advance.
phildunlap last edited by
Did you try
Jared Wiltshire last edited by
If you use a string as the first argument to the replace function it will only replace the first occurrence.
You should define a AngularJS filter or controller in a user module for something like this.
Yes thanks guys for the explanation and link.