Angular & Signals (283 Qs)•Part 6: Decorators, Dependency Injection & Tooling (124 - 150)
What are the class decorators in Angular?
A class decorator is a decorator that appears immediately before a class definition, which declares the class to be of the given type, and provides metadata suitable to the type
The following list of decorators comes under class decorators,
- @Component()
- @Directive()
- @Pipe()
- @Injectable()
- @NgModule()
Practical Code Example
typescript
// Class Decorators in Angular:
@Component({ selector: 'app-root', template: '' }) export class AppComp {}
@Directive({ selector: '[appBold]' }) export class BoldDir {}
@Pipe({ name: 'truncate' }) export class TruncPipe {}
@Injectable({ providedIn: 'root' }) export class ApiService {}