Get a value from mdInput

只愿长相守 提交于 2019-12-25 09:16:47

问题


So I have a md-input and some button.

<md-input-container >
   <input mdInput #myInput name="myInput" type="password" placeholder="Yeah">
</md-input-container>
<button md-raised-button (click)="authenticate(myInput)">Start</button>

This button sends the whole md-input. I fill in my input and that's what I'm getting when I click the button

<input _ngcontent-uqn-44="" mdinput="" name="myInput" placeholder="Yeah" type="password" ng-reflect-placeholder="Yeah" ng-reflect-type="password" class="mat-input-element" ng-reflect-id="md-input-1" id="md-input-1" aria-describedby="">

I don't see any property/attribute which contains the value I pasted in Input. So how could I get the value? Like myInput.value?


回答1:


I don't see any issue with your code, there may be something else which is causing issue.

<md-input-container >
    <input mdInput #myInput name="myInput" type="password" placeholder="Yeah">
 </md-input-container>
 {{myInput.value}}

Check this Plunker!



来源:https://stackoverflow.com/questions/42513925/get-a-value-from-mdinput

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!