对象在文本框中

时间:2016-08-04 13:10:14

标签: angularjs

我有一个引导模型

<div id="otpModal" class="modal fade" role="dialog">
          <div class="modal-dialog">

                <!-- Modal content-->
                <div class="modal-content">
                  <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                    <h4 class="modal-title">Enter OTP</h4>
                  </div>
                  <div class="modal-body">
                    <form class="form-otp" name="otp" ng-submit="enterOtp()" >

                        <div class="row col s6">
                                     <p>A verification code has been sent to your mobile by SMS. Please enter the verification code.
                                        </p>
                                    <input type="text" id="otp" placeholder="enter your OTP code" name="otpName" class="validate" maxlength="6" ng-pattern="/^[0-9]{4,6}$/" ng-model="otp" required>     
                        </div>
                        <p id="otpMsg" style="color:#e52424"></p>

                        <a href="#" ng-click="resendOtp()">Resend ?</a>
                        <button type="submit" ng-disabled="form-otp.$invalid" class="waves-effect waves-light btn done">
                                   <i class="material-icons left">done</i> Done
                        </button>
                    </form>
                  </div>

                </div>

              </div>
          </div>

我有一个控制器,其中enterOtp()&amp; resendOtp()已定义。问题是名称为&#34; otpName&#34;的文本框;正在显示[object Object]。

1 个答案:

答案 0 :(得分:0)

尝试更改

ng-model="otp"

ng-model="otp.name"

您可能使用了错误的字段作为ng-model。