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.
URL query variables
-
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=6I 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
?MagicalVariableto 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-paramsdirective 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=4Cheers!
-Shaun -
@shaun The
state-paramsdirective 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
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login