javascript / beginner
Snippet
Defining a Component Class
In Angular, components are defined using JavaScript classes. The class is a blueprint that contains the data and logic for a specific part of your application.
snippet.js
1
2
3
4
5
6
7
@Component({selector: 'app-root',template: '<h1>Hello</h1>'})export class AppComponent {appName = 'My App';}
angular
Breakdown
1
export class AppComponent
Creates a new class that can be exported and used in other files.
2
appName = 'My App'
A property that stores a string value within the component.