Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Initial value of datepicker (angular-ui) isn't shown

I use the following code

<pre>Selected date is: <em>{{tournament.startDate | date:'fullDate' }}</em></pre>
<input name=startDate" id="startDate" type="text" class="form-control" uib-datepicker-popup="{{format}}" ng-model="tournament.startDate" is-open="popup1.opened"
                         ng-required="true" close-text="Schließen""
                         datepicker-options="dateOptions" alt-input-formats="altInputFormats" />
                     <span class="input-group-btn">
                        <button type="button" class="btn btn-default" ng-click="open1()"><i class="glyphicon glyphicon-calendar"></i></button>
                    </span>

and my controller

$scope.tournament = Tournament.get({id: $routeParams.id});

    $scope.dateOptions = {
        dateDisabled: false,
        formatYear: 'yy',
        maxDate: new Date(2020, 5, 22),
        minDate: new Date(),
        startingDay: 1
    };

The value of tournament.startDate is shown in the pre-Tag but not in the input field. The opened datepicker show the correct date.

It seems to be a synchronized problem, cause if I change the controller to

$scope.tournament = new Object();
$scope.tournament.startDate = new Date();

the date is shown in the input field.

Edit: The scope is filled with the correct date but the inputfield don not show the value.

Thanks for help chokdee

like image 352
chokdee Avatar asked Oct 17 '25 03:10

chokdee


1 Answers

Found it by mself, that the REST Service give back a String not a Date object, after converting it it's working fine.

But in my opinion angular-ui should raise an exception if the cannot convert the given object.

like image 180
chokdee Avatar answered Oct 21 '25 16:10

chokdee