• Recent
    • Tags
    • Popular
    • Register
    • Login

    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.

    Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website Mango 5 Documentation Website

    Help with a global replace on a string in a directive

    How-To
    3
    4
    1.2k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P
      Phillip Weeks
      last edited by Phillip Weeks

      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.

      1 Reply Last reply Reply Quote 0
      • phildunlapP
        phildunlap
        last edited by

        Did you try .replace(/X/g, 'Y') ?

        1 Reply Last reply Reply Quote 0
        • Jared WiltshireJ
          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.
          https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace

          I 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.

          Developer at Radix IoT

          1 Reply Last reply Reply Quote 0
          • P
            Phillip Weeks
            last edited by

            Yes thanks guys for the explanation and link.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post