我正在使用Angular.js和html开发一个应用程序我想在我在.js文件中计算的选择组合框中绑定一个默认日期,但ng-model不会将我绑定到预期值。 这是html的代码:
<select ng-options="day as day for day in departureDateDays" ng-model="beginDateDay">
</select>
这就是我如何计算beginDateDay的值:
var defaultDate = new Date();
defaultDate.setUTCDate(defaultDate.getUTCDate() + parseInt(data.departure.date.default,10));
$scope.beginDateDay = defaultDate.getUTCDate();
$scope.test = $scope.beginDateDay;
$scope.departureDateMonths = getMonthRange($scope.departureMinYear,$scope.departureMinMonth,$scope.departureMaxYear,$scope.departureMaxMonth);
$scope.departureDateMonth = defaultDate.getUTCFullYear() + "-" + (defaultDate.getUTCMonth() + 1);
我希望得到一些帮助。