After clicking the search button and the radio button, I am converting the date format. Everything works fine when I search by date, but I encounter a problem when I click the radio button.
HTML Code
<form action="{{URL::current()}}" ng-submit="submit(item)">
<div class="form-group">
<label class="control-label">@lang('app.date')</label>
<div class="input-group ui-datepicker">
<input type="text" class="form-control datepicker"
uib-datepicker-popup name="enddate"
ng-model="item.enddate" is-open="enddate_opened"
ng-click="enddate_opened = !enddate_opened"/>
</div>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary">
<i class="fa fa-search"></i> @lang('search.search')
</button>
</div>
<!-- //////////Radio button//////////////////////-->
<div class="radio">
<label>
<input type="radio" name="log_date" value="log_date"
onchange="this.form.submit()">
@lang('product.invoice_date')
</label>
</div>
</form>
AngularJs Code
$scope.submit = function (item) {
angular.forEach(item, function (value, key) {
var val = value instanceof Date ? moment(value).format('YYYY-MM-DD') : value;
$('form [name=' + key + ']').val(val);
});
};
The URL result after clicking the search button:
enddate=2017-01-10
The URL result after clicking the radio button:
enddate=10%2F01%2F17
Both buttons are called from the same method, so why is the result different?