我有这个JSON对象:
项目= {"出发":"纽约","到达":"加州","电台&#34 ;:[{"台":" TOTO"},{"台":"蒂蒂"},{"台&# 34;:"塔塔"}]}
我有这个代码可以将这个Object填充到UI中:
<div class="panel-body panelcolor">
<div *ngIf="items?.departure">
<span>{{items.departure}}</span> -->
<span *ngIf="items.stations.length > 0">
{{items.stations[0].station}}
</span>
<span *ngIf="items.stations.length === 0">
{{items.arrival}}
</span>
<div class="input-group spinner">
<input type="text" formControlName="price" class="form-control">
<div class="input-group-btn-vertical">
<button (click)="spinnerPriceUp()" class="btn btn-default"
type="button"><i class="fa fa-caret-up"></i></button>
<button (click)="spinnerPriceDown()" class="btn btn-default"
type="button"><i class="fa fa-caret-down"></i></button>
</div>
</div>
</div>
<div *ngFor="let item of items.stations; let i=index, let last = last">
<div *ngIf="!last">
<span>{{item.station}}</span> --> <span *ngIf="items.stations[i+1]">
{{items.stations[i+1].station}}</span>
<div class="input-group spinner">
<input type="text" formControlName="price" class="form-control">
<div class="input-group-btn-vertical">
<button (click)="spinnerPriceUp()" class="btn btn-default"
type="button"><i class="fa fa-caret-up"></i></button>
<button (click)="spinnerPriceDown()" class="btn btn-default"
type="button"><i class="fa fa-caret-down"></i></button>
</div>
</div>
</div>
</div>
<div *ngIf="items?.arrival && items?.stations.length > 0">
<span>{{items.stations[items.stations.length-1].station}}</span> -->
<span>{{items.arrival}}</span>
<div class="input-group spinner">
<input type="text" formControlName="price" class="form-control">
<div class="input-group-btn-vertical">
<button (click)="spinnerPriceUp()" class="btn btn-default"
type="button"><i class="fa fa-caret-up"></i></button>
<button (click)="spinnerPriceDown()" class="btn btn-default"
type="button"><i class="fa fa-caret-down"></i></button>
</div>
继承人生成的UI: UI generated
我的问题是,当我点击提交按钮时,我怎么能得到这个Json对象:
{object:[{&#34; name&#34;:&#34; new york - toto&#34;,&#34; price&#34;:&#34; value&#34;},{ &#34; name&#34;:&#34; toto - mama&#34;,&#34; price&#34;:&#34;值&#34;},{&#34; name&#34;: &#34; mama - titi&#34;,&#34;价格&#34;:&#34;价值&#34;}, {&#34; name&#34;:&#34; titi - tata&#34;,&#34; price&#34;:&#34;值&#34;},{&#34; name&#34; :&#34; tata - california&#34;,&#34;价格&#34;:&#34;价值&#34;},{&#34;名称&#34;:&#34;纽约 - 加州& #34;,&#34;价格&#34;:&#34;价值&#34;}]}
PS: json对象中提到的值是UI中的价格(整数)的值。