javascript / beginner
Snippet
Creating Custom Methods
Methods are functions declared inside a class. In Angular, you write methods to define how your component reacts to logic changes or data updates.
snippet.js
1
2
3
4
5
6
7
export class CounterComponent {count = 0;updateCount(amount) {this.count = this.count + amount;}}
angular
Breakdown
1
updateCount(amount) { ... }
Defines a custom function that accepts a parameter named 'amount'.