自动填充地址
美好的一天,伙计们 我正在尝试使用日本的邮政编码自动填充地址 我使用网上的 AjaxZip3.addr2
,它在 VueJS 中运行良好。它也以角度填充该字段,但是它没有绑定到我分配的 ngModel,我也尝试 console.log
该值,它是空的,尽管该字段中有数据。
<div class="item-wrapper">
<label>Postal Code</label> <input type="text" name="zip" placeholder="1010065"
formControlName="postal_code"
onkeydown="AjaxZip3.zip2addr(this,'','prefectual','city','address1');"
(change)="showAddress($event)">
</div>
<p>Please enter the address without symbols. Enter your zip code and your address will
be automatically entered.</p>
<div class="item-wrapper">
<label>Pref</label> <input [(ngModel)]="prefShow" name="prefectual" type="text"
placeholder="東京都" formControlName="prefectual">
</div>
<div class="item-wrapper">
<label>City</label> <input [(ngModel)]="cityShow" name="city" type="text"
placeholder="千代田区" formControlName="city">
</div>
<div class="item-wrapper">
<label>Town</label> <input [(ngModel)]="townShow" name="address1" type="text"
placeholder="西神田1-3-6 URTAKE Build.3F" formControlName="address1">
</div>
onkeydown 是触发自动补全的内联函数,里面的参数
是一旦邮政编码正确就会自动填充的输入字段。
我只是将脚本添加到我的 index.html 文件中
<script src="https://ajaxzip3.github.io/ajaxzip3.js" charset="UTF-8">
以自动填充 无论如何
,我是否可以获得它的返回值,以便我可以在我的 ts 文件中使用它?
AjaxZip3.zip2addr(this,'','prefectual','city','address1');
如果没有,是否还有其他方法可以做到这一点?
谢谢
Good day guys
I am trying to auto populate an address using postal code of Japan
I use AjaxZip3.addr2
that I got online and it works fine in VueJS . it also populates the field in angular, however it did not bind to the ngModel that I assigned, also I tried to console.log
the value and it is null, even though, there is data in the field.
<div class="item-wrapper">
<label>Postal Code</label> <input type="text" name="zip" placeholder="1010065"
formControlName="postal_code"
onkeydown="AjaxZip3.zip2addr(this,'','prefectual','city','address1');"
(change)="showAddress($event)">
</div>
<p>Please enter the address without symbols. Enter your zip code and your address will
be automatically entered.</p>
<div class="item-wrapper">
<label>Pref</label> <input [(ngModel)]="prefShow" name="prefectual" type="text"
placeholder="東京都" formControlName="prefectual">
</div>
<div class="item-wrapper">
<label>City</label> <input [(ngModel)]="cityShow" name="city" type="text"
placeholder="千代田区" formControlName="city">
</div>
<div class="item-wrapper">
<label>Town</label> <input [(ngModel)]="townShow" name="address1" type="text"
placeholder="西神田1-3-6 URTAKE Build.3F" formControlName="address1">
</div>
onkeydown is the inline function that triggers the auto complete , the parameters inside
are the input field that will auto populate once the postal code is correct .
I just add the script in my index.html file
<script src="https://ajaxzip3.github.io/ajaxzip3.js" charset="UTF-8">
for the auto populate to
work
Is there anyway I can get the return value of this so i can use it in my ts file ?
AjaxZip3.zip2addr(this,'','prefectual','city','address1');
If none , Is there any other approach on how to do this ?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论