Angular · Junior · Question 3 of 75

What does the @Component decorator describe?

@Component({
  selector: "app-user-card",
  template: `<h2>{{ name }}</h2>`,
  styles: `h2 { color: teal; }`,
})
export class UserCard {
  name = "Ann";
}

Explanation

The decorator turns a plain TypeScript class into a component. selector is the tag you use in other templates (<app-user-card />), template/templateUrl is the markup, styles/styleUrl are the scoped styles.

Further reading

Problem with a question

Angular · Junior · question 3

Test yourself

Take the Angular · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz