katemihalikova / ion-datetime-picker

Date and/or time picker for awesome Ionic framework
MIT License
168 stars 101 forks source link

Is it possible to assign a specific date to the popup? #2

Closed finddoc closed 8 years ago

finddoc commented 8 years ago

It seems it always shows the current time when the picker popup, is it possible to assign it with a specific date? Thanks.

katemihalikova commented 8 years ago

Of course it is. Provided ng-model value is always respected.

    $scope.datetimeValue = new Date(2015, 5, 10, 14, 55, 5);
    <ion-item ion-datetime-picker ng-model="datetimeValue">
        {{datetimeValue| date: "yyyy-mm-dd H:mm:ss"}}
    </ion-item>

Both shown value and default picker value will be set to 2015-06-10 14:55:05.

WangShayne commented 8 years ago

Hi Kate!I try doing that,but it's look does't work. my code: $rootScope.search = { "query": { "areaId": "", "locationId": "", "startDate": new Date(), "endDate": new Date(), "startTime": new Date(9,0), "endTime": new Date(10,0), "equipment":{ "hasProjector":"", "hasMic":"", "hasBoard":"" } } }; html <span>{{search.query.startTime | date: "HH:mm"}}</span> After the loading, it's look like "00:00" sorry my English is bad

katemihalikova commented 8 years ago

Date uses this syntax: new Date(year, month, day, hour, minute, second). You need to use new Date(0, 0, 0, 9, 0, 0) for 9:00.

WangShayne commented 8 years ago

thanks a lot!!