本文介绍了从 mdInput 获取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个 md-input 和一些按钮.

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>

这个按钮发送整个md-input.我填写了我的输入,这就是我点击按钮时得到的

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="">

我没有看到任何包含我粘贴到 Input 中的值的属性/属性.那么我怎样才能获得价值呢?像 myInput.value?

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?

推荐答案

我看不出您的代码有任何问题,可能是其他原因导致了问题.

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}}

检查这个 Plunker!

这篇关于从 mdInput 获取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 19:34