目前我在导航项目中工作,我从用户那里得到两个输入作为经度和纬度。输入应该一个接一个地给出。我想要的是将这两个输入作为一个用逗号分隔的输入,这样如果我输入like 41.23,34.32,它位于经度41.23和纬度34.32的位置。
目前我的代码是:
<div *ngIf="data.mod=='goLocation'" class="panel-body">
<form #f="ngForm" (ngSubmit)="go(f.value); f.reset();" class="settings-form">
<table>
<tr>
<td>
<mat-form-field>
<input matInput placeholder="Enlem(Y)" name="lat" id="lat" #lat="ngModel" ngModel required>
<mat-error *ngIf="lat.touched && lat.invalid">
<div *ngIf="lat.errors.required">Bu alanı boş geçemezsiniz.</div>
</mat-error>
</mat-form-field>
</td>
<td>
<mat-form-field>
<input matInput placeholder="Boylem(X)" name="lon" id="lon" #lon="ngModel" ngModel required>
<mat-error *ngIf="lon.touched && lon.invalid">
<div *ngIf="lon.errors.required">Bu alanı boş geçemezsiniz.</div>
</mat-error>
</mat-form-field>
</td>
</tr>
</table>
<button [disabled]="!f.valid" class="btn btn-outline-primary">Git</button>
</form>
</div>
&#13;
答案 0 :(得分:1)
只是在(改变)分裂
<input #latlon (change)=changeLatLon(latlon.value)>
changeLatLon(value:any)
{
let latlog=value.split(',');
this.lat=latlon[0];
this.lon=latlon.length>1?latlog[1]:0; //if latlon haven't a ",",
// latlong.length=1
}
答案 1 :(得分:0)
感谢Eliseo,以下代码完成了工作。
<div v-on:click="doSomethingWith" v-for="user in users">
<span>
<div>
<a>
<div class="img-wrapper">
{{ user.picture }}
</div>
</a>
</div>
</span>
<span>
<span><span><a>{{ user.name }}</a></span></span>
<span><span><a>{{ user.mobile }}</a></span></span>
</span>
</div>