2016-04-05 5 views
1

私はIE 9/10で奇妙な問題に直面しています。双方向バインディングは、ドロップダウンを除くすべてのhtml要素に対して機能します。 ドロップダウンで値が選択されません。ドロップダウンに値が存在しています。IE 2ウェイ・ドロップダウン・バインディングの問題点が角2である

ここにサンプルコードを示します。

HTML

<select [(ngModel)]="model.city" id="city"> 
    <option value="Lahore">Lahore</option> 
    <option value="Karachi">Karachi</option> 
</select> 

TS(Angular2)IEで上記の条件では動作しませ結合

this.model.city="Karachi"; 

双方向。

IEに必要なすべてのシムを含めましたが、選択されていません。

<script src="node_modules/es6-shim/es6-shim.min.js"></script> 
<script src="node_modules/angular2/es6/dev/src/testing/shims_for_IE.js"></script> 
<script src="node_modules/angular2/bundles/angular2-polyfills.js"></script> 

答えて

0

これは、それがデフォルトで角度によって提供されるまで手動リンクPRからSelectControlValueAccessorを追加することで回避することができ、既知の問題

です。

他の回避策については、Selects' events in Angular2およびAngular2 access a select event change within the componentも参照してください。

+0

リンクされた問題は解決済みとマークされます。しかし、Angular RC5の最新バージョンでIEにはまだ問題があります。 – Johannes

0

HTML

<select class="classic" [(ngModel)]="city" id="selectoption"> 
      <option *ngFor="#city of cityValues">{{city}}</option> 
    </select> 

TS(Angular2)

public cityValues:Array<any>; 
    public city:any 

    //Add below line in constructor 

    this.cityValues=["Lahore","Karachi"]; 

//get the selected value using javascript 

var getSelectedId= document.getElementById('selectoption'); 
var getSelectedValue=getSelectedId.options[getSelectedId.selectedIndex].text; 
this.city=getSelectedValue; 

*注:type.Itは、実行時に値を取得する以上jsのコードに示すエラー。

関連する問題