Angular 如何在没有表单的情况下通过单击事件发送评级值

Angular 如何在没有表单的情况下通过单击事件发送评级值,angular,parameter-passing,Angular,Parameter Passing,我有一个带有10颗星的评级系统的对话框。我想用点击事件将填充星的值作为数字发送到类型脚本文件,这样我就可以通过http请求将其发送到数据库 <h2 mat-dialog-title>Rate sitter {{ sitter.firstname }} {{ sitter.lastname }}</h2> <mat-dialog-content class="mat-body-1"> <ngb-rating [(rate)]="currentRate"

我有一个带有10颗星的评级系统的对话框。我想用点击事件将填充星的值作为数字发送到类型脚本文件,这样我就可以通过http请求将其发送到数据库

<h2 mat-dialog-title>Rate sitter {{ sitter.firstname }} {{ sitter.lastname }}</h2>
<mat-dialog-content class="mat-body-1">
  <ngb-rating [(rate)]="currentRate">
    <ng-template let-fill="fill">
      <span class="star" [class.filled]="fill">&#9733;</span>
    </ng-template>
  </ngb-rating>
  <hr>
  <pre>Rate: <b>{{currentRate}}</b></pre>
</mat-dialog-content>
<mat-dialog-actions>
  <button mat-button mat-dialog-close>Cancel</button>
  <button mat-button (click)="rateSitter()" [mat-dialog-close]="true">Rate</button>
</mat-dialog-actions>
Rate sitter{{sitter.firstname}{{sitter.lastname}
★

速率:{{currentRate} 取消 比率
如果不需要将其放入表单中,我如何执行此?我应该将什么作为参数传递给单击事件的函数

您可以使用(费率更改)

<ngb-rating
    [(rate)]="rating"
    [starTemplate]="t"
    [readonly]="readOnly"
    [max]="max"
    (hover)="isRating = true; hovered = $event"
    (leave)="isRating = false; hovered = 0"
    (rateChange)="onRateChange($event)">
</ngb-rating>
onRateChange(rating :number) {        

    // save or send your rating value

}