What are the parts of a component?
Model answer
A component has a class with the data and methods, a template with the HTML the user sees, optional styles scoped to that component, and metadata in the @Component decorator: selector (the tag name), imports (what the template uses), templateUrl or template, and styleUrl or styles.
The class and template are connected: the template can show class data with interpolation and call class methods in response to events.
Learn this topic
Angular Tutorial: Beginner to Advanced .
Sign in to add your own answer.
More questions
- What is data binding? Explain the four types.
- What is the difference between interpolation and property binding?
- How do you pass data from a parent component to a child component?
- How does a child component send data to its parent?
- What is the component lifecycle? Describe the main hooks.
- What is the difference between the constructor and ngOnInit?