javascript - Multiple submit buttons in angular2 form -
i building angular2 form , have multiple buttons submit form, e.g "save" , "save , close".
i have tried use simple buttons click action on them, didn't find anyway manually mark form submitted force form validation.
<form #ticketform="ngform" novalidate> <input type="text" id="customername" required name="customername" [(ngmodel)]="ticket.customername" #customername="ngmodel"> <div class="tj-form-input-errors" *ngif="customername.errors && (customername.dirty || customername.touched || ticketform.submitted)"> <small [hidden]="!customername.errors.required"> customer name required </small> </div> <button type="button" (click)="save(ticketform)">save</button> <button type="button" (click)="saveandclose(ticketform)">save , close</button> </form>
you can subscribe form changes, think fire form validation.
i this:
this.physicalform.valuechanges .map((value) => { return value; }) .filter((value) => this.physicalform.valid) .subscribe((value) => { need values here... });
then in click handler each button, if this.physicalform.valid
save or save&update.
Comments
Post a Comment