app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
counter:number = 0;
getValue(isIncrement:boolean){
if(isIncrement){
this.counter++;
}else{
this.counter--;
}
}
}
app.component.html
<h2>Angular Counter Example</h2>
<h3>
Counter : {{counter}}
</h3>
<button
(click)="getValue(true)"
style="padding:12px;">
Increment
</button>
<button
(click)="getValue(false)"
style="padding:12px;">
Decrement
</button>
- angular - How to use Button click event
- angular - How to call function on Button click
- angular - Text input on change listener
- angular - How to get text input value
- angular - Generate random number in range
- angular - Generate random whole number
- angular - How to submit form data
- angular bootstrap - Rating hover event
- angular bootstrap - Readonly & editable Rating
- angular bootstrap - How to show Toast message
- angular bootstrap - How to use Popover
- angular bootstrap - Open Popover on mouse hover
- angular bootstrap - Open close Popover on button click
- angular material - How to use Button toggle group
- angular material - Button toggle group multiple selection