1

我的日期是 UNIX 时间戳,

dateOfBirth = 1384369855;
$scope.dob = dateOfBirth;

在我看来,我怎样才能将它传递给具有三个字段的模型,一个forday和?monthyear

4

1 回答 1

3

HTML

<div ng-app ng-controller="MyCtrl">
    days:   <select ng-model="selectedday" ng-options="selectedday for selectedday in days"></select>
    month:  <select ng-model="selectedmonth" ng-options="selectedmonth for selectedmonth in months"></select>
    years:  <select ng-model="selectedyear" ng-options="selectedyear for selectedyear in years"></select>    
</div>

JS

    $scope.days = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31];
    $scope.months = ['January','February','March','April','May','June','July','August','September','October','November','December'];
    $scope.years = [2010,2011,2012,2013,2014];

     $scope.theDate = new Date(1384369855000);

    $scope.selectedyear = $scope.theDate.getFullYear();
    $scope.selectedmonth = $scope.months[$scope.theDate.getMonth()];
    $scope.selectedday = $scope.theDate.getDate();   

演示Fiddle

于 2013-11-13T19:13:52.767 回答