Angular - 如何在按钮中添加金额?

Angular - How can I add amounts in a button?

我的问题是,我无法在按钮中添加金额。

我的代码如下所示:

navbar.component.html:

<button>0,00$</button>
<button function="onClick()">Add 5</button>

navbar.component.ts

import { Component, ElementRef, ViewChild } from '@angular/core';

@Component({
  selector: 'app-navbar',
  templateUrl: './navbar.component.html',
  styleUrls: ['./navbar.component.scss'],
})
export class NavbarComponent {

  onClick(){
    //add 5 when clicked
  }


}

如果有人能帮助我,我将不胜感激。我无法让它工作,如果我点击带有功能的按钮,我可以将 5 美元添加到另一个按钮。

谢谢!

请尝试=>
HTML:

<button>{{sumValue}}</button>
<button (click)="onClick()">Add 5</button>

TS:

export class AppComponent  {
  sumValue:number=0;
  onClick(){
    this.sumValue=this.sumValue+5;
  }
}