首页 文章

如何使用Google Api进行Angular js验证

提问于
浏览
0

我是angularjs的新手,并试图在谷歌API示例`上实现角度验证

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

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

角度验证代码是

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

但是当我写出城市,州和国家本身时,一切都运转良好 . 那么我怎样才能将它与谷歌api一起使用

1 回答

  • 0

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

    希望这可以帮助!

相关问题