Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.
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. -
Did you try
.replace(/X/g, 'Y')
? -
If you use a string as the first argument to the replace function it will only replace the first occurrence.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceI am pretty sure that a RegExp wont work in an AngularJS expression. AngularJS expressions are JavaScript like but not actually JavaScript - https://docs.angularjs.org/guide/expression
You should define a AngularJS filter or controller in a user module for something like this.
-
Yes thanks guys for the explanation and link.