我想以角度将选择选项数据发送到节点js服务器 这是我的html
<div class="col-md-4 col-sm-12 col-xs-12">
<div class="form-group">
<label for="select1">Zone</label>
<select #zone class="form-control" id="select1">
<option disabled="disabled">Select Zone</option>
<option >zone-1</option>
<option>zone-2</option>
<option >zone-3</option>
<option >zone-4</option>
<option >zone-5</option>
<option >zone-6</option>
</select>
</div>
</div>
<div class="get-btn1">
<a (click)="analyticDataSend(zone.value)" class="btn btn-success">Start</a>
</div>
这是我的交易代码
analyticDataSend(zone: string) {
this.http.post('http://localhost:8012/sendmail', zone).subscribe();
console.log(zone)
}
答案 0 :(得分:1)
您不能在发布请求中发送字符串,它必须是json对象。如下所示:
analyticDataSend(zone: string) {
this.http.post('http://localhost:8012/sendmail', {'zoneName':zone}).subscribe();
console.log(zone)
}