Cambia URL dinamicamente a seconda del valore del datepicker Angular.js
-
26-12-2019 - |
Domanda
<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"/>
.
La rotta URL è:
GET /admin/api/stats controllers.AdminStatsApi.get(start: Option[LocalDate], end: Option[LocalDate], computeDiff: Boolean ?= false)
La mia domanda è come posso modificare l'URL a seconda della data (valore) inserita nel datepicker
.
Soluzione
Hai fornito informazioni insufficienti.Cosa usi?UI-router?$ Posizione?
Ma fondamentalmente puoi fare qualcosa del genere:
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);
. Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow