How to set this value on loading the page
-
I have a set of buttons that pass in from and to dates with a rollup-interval but this is not set when the page loads.
How can I set this value in entry to the setting "1 minutes"
<ma-now update-interval="1 minutes" output="to"></ma-now> <ma-calc input="now | moment:'subtract':subtractX:subtractUnit" output="from"></ma-calc> <md-button class="md-raised" ng-click="subtractX=1;subtractUnit='day'; rollupInterval='1 minutes'">Last 24 hours</md-button> <md-button class="md-raised" ng-click="subtractX=7;subtractUnit='day'; rollupInterval='10 minutes'">Last week</md-button> <md-button class="md-raised" ng-click="subtractX=30;subtractUnit='day'; rollupInterval='30 minutes'">Last month</md-button> <ma-point-values point="oilbbl1" values="oilbbl1Values" from="from" to="to" rollup="AVERAGE" rollup-interval="{{rollupInterval}}"></ma-point-values>
-
You will want to use ng-init. you can pretty much put it anywhere on the page but I usually put them on a parent div or just drop one in like:
<div ng-init="rollupInterval='1 minutes'"><div>
You can put any angular expressions in ng-init similar to what you are doing on ng-click. The code will just be run automatically run on page load rather then after a click event.