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 Guys.. anyone know if I can replace 10000 with variable? can I inject a variable I initialize with ng-init="myvar=10000;" into this code?
    onclick="setTimeout(function() { location.reload(); }, 10000);clearTimeout(this);"
    with
    onclick="setTimeout(function() { location.reload(); }, myvar );clearTimeout(this);"


  • Yes provided myVar is a global variable in your window object.


  • Does ng-init create a global variable


  • No, it creates a variable on the AngularJS scope where you declare it.

    Maybe post a full explanation of what you are trying to accomplish.


  • ok I would like to set a angular variable Adjust=false 10 seconds after it is set to true by an ng-click. So I did not know how to do this but when I refresh the screen notice page resets Adjust=false on ng-init so this was a just a way to reset the variable because I didn't know another way. Is there a way I can use <ma-calc with time to set the value false. I have only used ma-calc to evaluate and expression to true or false then use this output variable in the ng-show however if I give output the same name as Adjust where iit is already created will it re-create or update the variable?
    ie.
    <ma-calc input="Adjust&&!time.seconds() >= 10" output="Adjust"></ma-calc>


  • @phillip-weeks said in Help with scripting:

    ok I would like to set a angular variable Adjust=false 10 seconds after it is set to true by an ng-click.

    Not following the rest of the paragraph, its not very clear so I'm just going to respond to this first part.

    <div class="ma-designer-root" id="0c3ce01e-c415-4192-a638-e1e9a8148243" style="width: 1366px; height: 768px; position: relative;" ng-init="page = {}">
        <ma-button id="ffc38ad4-1d9e-4aa5-84d7-924132cdd70f" raised="true" style="position: absolute; left: 131px; top: 70px;" label="Click me" ng-click="page.textVisible = true; page.firstTick = true"></ma-button>
        <div id="4483a29a-3ff9-4792-94b3-eaa724bc8b54" style="position: absolute; left: 375px; top: 272px;" ng-show="page.textVisible">Text visible</div>
        <ma-now id="da77aae1-f031-4e13-a241-4e038d1ec11e" ng-if="page.textVisible" style="position: absolute; left: 400px; top: 80px;" update-interval="10 seconds" on-change="page.firstTick ? page.firstTick = false : page.textVisible = false"></ma-now>
        <pre id="c81e362b-d4d5-46c2-8e3e-234a4a8c1cd6" style="position: absolute; left: 352px; top: 277px;" ng-bind="page | json"></pre>
    </div>
    

    Note the ng-init to create an object on the outside scope. This is needed otherwise setting a value in the ma-now directive's on-change attribute will only set the value for its local scope.


  • @jared-wiltshire Thank-you so much Jared; I have it working now thanks to your help, And a great help indeed.