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

  • 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


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


  • 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


  • @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).


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

    Cheers!
    -Shaun