4
我有下面的代碼片段:動態設置ngModelOptions在角
<input type="date" ng-model="arrival" ng-model-options="{timezone: 'PST'}" />
<input type="time" ng-model="arrival" ng-model-options="{timezone: 'PST'}" />
{{arrival}}
可以正常工作(日期顯示,從PST轉換UTC時間)。現在我努力使「PST」選項動態:
<select ng-model="timezone>
<option value="PST">PST</option>
<option value="EST">EST</option>
</select>
<input type="date" ng-model="arrival" ng-model-options="{timezone: timezone}" />
<input type="time" ng-model="arrival" ng-model-options="{timezone: timezone}" />
{{arrival}}
但是,更改時區從不更新的到來(似乎綁定不nd-model-options
工作)。任何方式我可以強制時區更改時刷新字段?
編輯
小提琴:https://jsfiddle.net/10nfqow9/
嘗試具有以ng-模型選項的對象,是這樣的: 'NG-模型選項= 「選項」' 和 '$ scope.options = {timezone:$ scope.timezone}' –
@NMittal沒有什麼區別。 –