根据日期选择器的值动态更改 URL Angular.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
.
解决方案
您提供的信息不足。你用什么?用户界面路由器?$地点?
但基本上你可以做类似的事情:
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