自动填充地址

发布于 01-18 00:39 字数 1741 浏览 2 评论 0原文

美好的一天,伙计们 我正在尝试使用日本的邮政编码自动填充地址 我使用网上的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文