InterviewHubPRO
Section Overview
Q125

Question 125 of 283

Part 6: Decorators, Dependency Injection & Tooling (124 - 150)

44%
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,

  1. @Component()
  2. @Directive()
  3. @Pipe()
  4. @Injectable()
  5. @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 {}