• 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

    URL query variables

    Dashboard Designer & Custom AngularJS Pages
    2
    5
    2.3k
    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.
    • S
      shaun
      last edited by

      Hi All,

      I'm trying to pass a variable via URL into a dashboard to pre-select something...

      Example URL would be:
      http://mango/user-dashboards/testing/Power/device?MagicalVariable=6

      I want to use MagicalVariable to populate an <md-select> default.

      I see from here: https://docs.angularjs.org/api/ng/service/$location
      there is a $location.search() function in AngularJS, but I'm not really sure how to use it. So far I've been unsuccessful with what i've tried.

      Cheers!
      -Shaun

      1 Reply Last reply Reply Quote 0
      • Jared WiltshireJ
        Jared Wiltshire
        last edited by Jared Wiltshire

        Hey @shaun can you let me know

        • Your Dashboards module version
        • Which template you are using (or if you are using a custom page)

        If you are using the adminTemplate, you can add ?MagicalVariable to the end of your page's URL in app.js
        e.g.

            {
                name: 'dashboard.demoPage1',
                url: '/demo-page-1?MagicalVariable',
                linkToPage: true,
                pageXid: 'demo-page-1',
                menuText: 'Demo Page 1',
                menuIcon: 'favorite'
            },
        

        Then in your page's markup you can use the state-params directive to retrieve it

        <state-params state-params="stateParams"></state-params>
        <div>Variable is {{stateParams.MagicalVariable}}</div>
        

        We use Angular UI Router 0.3.x in our application if you want to read more about the state parameters and URLs.

        Developer at Radix IoT

        1 Reply Last reply Reply Quote 0
        • S
          shaun
          last edited by

          Hi Jared,

          Dasboard Module version is 3.2.4
          I'm using the adminTemplate.

          I virtually cut and paste from your code above, but it didn't work. I also get nothing if in the html i just put in {{stateParams}}. I'd expect to see something from that... is there something else I need to do?

          {
            name: 'dashboard.power.Rack',
            templateUrl: 'views/Power/Rack.html',
            url: '/rack?rackSelect',
            linkToPage: true,
            menuText: 'Rack'
          },
          
          <state-params state-params="stateParams"></state-params>
          <div>Variable is {{stateParams.rackSelect}}</div>
          

          URL in the browser:

          http://host/user-dashboards/dev/Power/rack?rackSelect=4
          

          Cheers!
          -Shaun

          1 Reply Last reply Reply Quote 0
          • Jared WiltshireJ
            Jared Wiltshire
            last edited by

            @shaun The state-params directive is only included in the mdAdmin project, you will need to copy it into your copied adminTemplate folder and add it to app,js (as per the login directive in that file, let me know if you need help).

            Developer at Radix IoT

            1 Reply Last reply Reply Quote 0
            • S
              shaun
              last edited by

              Thanks @Jared-Wiltshire I'll give it a go!

              Cheers!
              -Shaun

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