Datepickerの値angularに応じてURLを動的に変更します。js
-
26-12-2019 - |
質問
<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"/>
URLルートは次のとおりです :
GET /admin/api/stats controllers.AdminStatsApi.get(start: Option[LocalDate], end: Option[LocalDate], computeDiff: Boolean ?= false)
私の質問は、入力された日付(値)に応じてURLを変更するにはどうすればよいですか datepicker
.
解決
あなたは不十分な情報を与えています。あなたは何を使いますか?ui-ルーター?◎場所は?
しかし、基本的にあなたはそのようなことをすることができます:
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);
所属していません StackOverflow