【问题标题】:How to use Angular js Validation with Google Api如何通过 Google Api 使用 Angular js 验证
【发布时间】:2017-04-06 00:42:21
【问题描述】:

我是 angularjs 的新手,正在尝试在 google API 示例上实现角度验证 `

https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete-addressform

当我输入地址时,它会自动填写州、市和县,但 angularjs 仍然给我错误,提示需要城市、州和国家,但这些数据已由 google api 自动填写

Angular 验证码是

<div class="col-md-3">
            <label for="email" class="control-label">*City:</label>
            <span class="help-block" ng-show="form.city.$invalid && form.city.$touched">
                <strong>*City is Required</strong>
            </span>
            <input class="form-control" ng-model="formdata.city" ng-required="true" name="city" value="<% formdata.city %>" id="locality" >

        </div> 

但是当我编写城市、州和国家本身时,一切正常。那么我如何将它与 google api 一起使用

【问题讨论】:

    标签: javascript angularjs google-maps autocomplete


    【解决方案1】:

    sample 相比,我认为您的编码方式没有任何错误。你可能想检查这个related SO post。它建议将消息​​的验证和显示、访问表单等与googlePlaces 指令隔离开来。这里还有一个 example from GitHub - 使用 Google Maps JavaScript API v3 和嵌入式自动完成验证器的 Angularjs 自动完成模块。

    希望这会有所帮助!

    【讨论】:

      猜你喜欢
      • 2013-08-18
      • 2018-12-28
      • 1970-01-01
      • 2013-08-02
      • 1970-01-01
      • 2017-03-06
      • 1970-01-01
      • 2013-02-09
      • 2019-06-03
      相关资源
      最近更新 更多