My goal is to develop a small web application where users can download data from a database within a specified time range. Below is the HTML code snippet that I have:
<div class="container">
<div class='col-md-5'>
Start Date:
<div class="form-group">
<div class='input-group date' id='datetimepicker6'>
<input type='text' ng-model="queryDate.start" class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
<div class='col-md-5'>
End Date:
<div class="form-group">
<div class='input-group date' id='datetimepicker7'>
<input type='text' ng-model="queryDate.end" class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
<div class='col-md-5'>
Service Name:
<select id="serviceName" style="font-size: 15px;padding: 5px;width: 300px" >
<option></option>
<option ng-repeat="webService in webServices">{{ webService.fields.service }}</option>
</select>
</div>
<div class='col-md-6'>
<button type="button" id="download" ng-click="download(queryDate)" class="btn btn-theme" style="float: right">Download</button>
</div>
</div>
I am aiming to capture both the start date and end date using ng-model.
ng-model="queryDate.start"
ng-model="queryDate.end"
Handling data from ng-model should be straightforward, as demonstrated in the AngularJS documentation here.
Here is my mainApp.js file:
var mainApp = angular.module("mainApp",[]);
mainApp.controller("serviceController",function($scope,$http){
$http.get("/fetchData/").success(function(response){
$scope.webServices = response;
});
//--------- I receive an alert saying "Hola," but the subsequent alert shows "undefined" ---------
$scope.download = function(queryDate){
alert('Hola');
alert(queryDate);
};
});
The intention is to gather input from the date fields and utilize them to fetch relevant data from the database.