如何使用“<a>` link tag to submit form in angular 4

时间:2017-09-28 08:34:26

标签: html angular typescript

I want to get the selected option in this form from the other side when clicking link.

<form (ngSubmit)="onSubmit(x)">
    <input type="radio" id="radioset3" name="radioset" [checked]="x==0">
    <input type="radio" id="radioset2" name="radioset" >
    <input type="radio" id="radioset1" name="radioset" >

    <a href="javascript:void(0)" class="flightdetails"><span><i class="fa fa-suitcase" aria-hidden="true"></i></span> Flight Details</a>
</form>

UPDATE

Css styled button did my job. I'm not good with css. That's why I was thinking about a tag.

1 个答案:

答案 0 :(得分:3)

可以使用(click)="..."处理程序提交表单

<a (click)="myFormSubmitHandler()" href="javascript:void(0)" class="flightdetails"><span><i class="fa fa-suitcase" aria-hidden="true"></i></span> Flight Details</a>

在点击处理程序中,使用HttpHttpClient模块向服务器发送帖子请求。