Hi everyone I have a custom range to pick a day in angularjs. I need a listener when i pick two days (start and end) to get the values and autoamtically send this data to my rest api.
View :
<div class="form-group col-md-3 mb0" ng-if="timerange == 'custom'" id="customDiv">
<div class="row">
<label class="col-sm-3 control-label pt7">Custom</label>
<div class="col-sm-9">
<input type="text" id="customrange" name="customrange" ng-model="parent.customrange" ng-change="applyOptions()" class="form-control" ui-jq="daterangepicker" ui-options="{format: 'YYYY/MM/DD',startDate: '{{startdate}}',endDate: '{{enddate}}', maxDate:'{{enddate}}'}" />
</div>
</div>
</div>
When i click in my range dropdownbox i choose custom and then it popups a input with a date picker.. I need when i press apply to get the data.. I read a lot of documentation and cant add a listener to this... I really need to find a way...
Controller:
var rangeSelector = document.getElementsByTagName('select')[1]; //1h 24h 1w custom
if(rangeSelector.value == 'custom'){
getDate = controllerScope.getStartEndTimestamps();
var datePicker = document.getElementById("customrange").getAttribute('ui-options');
var split = datePicker.split(",");
var startDate = "";
var endDate = "";
document.getElemenstByTagName("button")[0].addEventListener("click", function(){
alert("I've changed : ");
startDate = split[1].split(': ')[1].replace(/["']/g, '');
endDate = split[2].split(': ')[1].replace(/["']/g, '');
});
console.log("range selector ",rangeSelector);
console.log("startDate ",startDate);
console.log("endDate ",endDate);
if (startDate !== undefined) {
url += '&startDate='+startDate;
}
if (endDate !== undefined) {
url += '&endDate='+endDate;
}
}
Logs:
range selector …
startDate
endDate
The problem is the alert "I've changed" dont popup... is there a simple way to do this??