angular - Accessing Select element value in angular2 gives Error -
i'm using angular 2 rc4 view following:
<select class="form-control" (change)="selecttestname=this.value;getchartdata()"> <option *ngfor="let st of selecttestnamelist" value="{{st.selecttestname}}">{{st.selecttestname}}</option> </select>
after change throws following error:
typeerror: cannot read property 'value' of undefined @ debugappview._view_generaltrnd0._handle_change_20_0 (generaltrnd.template.js:367) @ eval (eval @ <anonymous> (vendor.js:25), <anonymous>:316:24) @ eval (eval @ <anonymous> (vendor.js:45), <anonymous>:278:36) @ eval (eval @ <anonymous> (vendor.js:48), <anonymous>:20:93) @ zonedelegate.invoke (zone.js:323) @ object.oninvoke (eval @ <anonymous> (vendor.js:17), <anonymous>:45:41) @ zonedelegate.invoke (zone.js:322) @ zone.runguarded (zone.js:230) @ ngzoneimpl.runinnerguarded (eval @ <anonymous> (vendor.js:17), <anonymous>:78:78) @ ngzone.runguarded (eval @ <anonymous> (vendor.js:13), <anonymous>:228:73)
try this:
<select class="form-control" #selectbox (change)="selecttestname=selectbox.value;getchartdata()"> <option *ngfor="let st of selecttestnamelist" value="{{st.selecttestname}}">{{st.selecttestname}}</option> </select>
you have assign name selectbox. can use name access value.
Comments
Post a Comment