This is my code:
$scope.date = new Date();
var date1 = new Date($scope.date);
var date2 = new Date(2017,5,5);
var diffDays = parseInt((date2 - date1) / (1000 * 60 * 60 * 24));
alert(diffDays);
the above code is working fine, but when I try pass model in js its not working, it is showing NaN
instead.
Here is my controller with model value
$scope.date = new Date();
var date1 = new Date($scope.date);
var date2 = new Date($scope.studyUser.Ethical_Committee_Approved_Date);
var diffDays = parseInt((date2 - date1) / (1000 * 60 * 60 * 24));
alert(diffDays);
here is my html code
<div class="col-sm-7">
<p class="input-group">
<input type="text" class="form-control" id="Ethical_Committee_Approved_Date"
uib-datepicker-popup="{{format}}"
is-open="datePicker.popup1.opened"
ng-model="studyUser.Ethical_Committee_Approved_Date"
datepicker-options="datePicker.dateOptions"
ng-required="true"
onkeydown="return false"
ng-click="datePicker.open1($event)"
readonly
alt-input-formats="altInputFormats"
ng-change="datePicker.changeMinAndMaxDates()">
<span class="input-group-btn">
<button type="button" class="btn btn-default" ng-click="datePicker.open1($event)">
<i class="glyphicon glyphicon-calendar"></i>
</button>
</span>
</p>
<span style="color:red" ng-show="addstudy.approvaldate.$invalid && addstudy.approvaldate.$dirty">Please Enter the Approval Date</span>
</div>