【发布时间】:2017-10-17 03:58:23
【问题描述】:
在我的角度值中,我可以选择更改时区。 this.userTimeZone 是我组件中的一个对象。
{
AdjustmentRules:null
BaseUtcOffset:"-04:30:00"
DaylightName:"Venezuela Daylight Time"
DisplayName:"(UTC-04:30) Caracas"
Id:"Venezuela Standard Time"
StandardName:"Venezuela Standard Time"
SupportsDaylightSavingTime:false}
我的选择选项如下所示:
<select name="timeZones" [(ngModel)]="userTimeZone" (change)="setTimezoneId($event)" class="form-control">
<option *ngFor="let time of timezones" [ngValue]="time">{{time.DisplayName}}</option>
</select>
我无法设置选择的初始值。
虽然 userTimeZone 有一个值,但加载时选择显示为空白。
如果我给 userTimeZone.Id 和 [ngValue]="time.id" 该选项会被选中,但更改时返回的值只是 id 而不是整个对象。
I want the entire object when the select option changes ans also set the initial value of the select.
不知道这里出了什么问题。请指导
谢谢
【问题讨论】: