JSFiddle - React, Tailwind, and code Playground
HTML
<div ng-app="app">
<form ng-submit="generate(unit, groupby)" ng-controller="AppCtrl">View from the last:
<select class="form-control" ng-model="range" ng-options="r for r in ranges"></select>
<select class="form-control" ng-model="unit" ng-options="(units.indexOf(u)) as u + '(s)' for u in units"></select>Grouped by:
<select class="form-control" ng-model="groupby" ng-options="units.slice(0, unit + 1).indexOf(g) as g for g in units.slice(0, unit + 1)"></select>
<input type="submit" value="Get Data" />
</form>
</div>
JavaScript
var app = angular.module('app', []);
app.controller('AppCtrl', function AppCtrl($scope, $http) {
$scope.ranges = [1, 2, 3, 4, 5, 6];
$scope.range = 3;
// options for time units
$scope.units = ["Day", "Week", "Month"];
// selected unit
$scope.unit = 0;
// selected grouping
$scope.groupby = 0;
// bound to form submit
$scope.generate = function (unit, groupby) {
//...
};
});