Changer l'URL dynamiquement en fonction de la valeur de datepicker angulaire.js
-
26-12-2019 - |
Question
<label>From</label>
<input type="text" datepicker-popup="dd-MM-yyyy" ng-model="StartDate"/>
<label>To</label>
<input type="text" datepicker-popup="dd-MM-yyyy" ng-model="EndDate"/>
L'itinéraire de l'URL est :
GET /admin/api/stats controllers.AdminStatsApi.get(start: Option[LocalDate], end: Option[LocalDate], computeDiff: Boolean ?= false)
Ma question est de savoir comment puis-je modifier l'URL en fonction de la date (valeur) saisie dans le champ datepicker
.
La solution
Vous avez donné des informations insuffisantes.Qu'est ce que tu utilises?ui-routeur ?$emplacement ?
Mais en gros, tu peux faire quelque chose comme ça :
var changeUrl = function(startDate, endDate){
//do url change with whatever thing you are using to change your url
}
$scope.$watch('StartDate', function(newValue){
var start = newValue;
var end = $scope.endDate;
//do your url change here
changeUrl(start, end);
}, true);
$scope.$watch('EndDate', function(newValue){
var start = $scope.startDate;
var end = newValue;
//do your url change here
changeUrl(start, end);
}, true);
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow