Angular

Angular Fundamentals

Components, templates, data binding, structural directives, ngFor, ngIf, interpolation, property binding, event binding

20 interview questionsยท
Junior
1

What is a component in Angular?

Answer

A component is a fundamental building block of an Angular application that controls a portion of the user interface. It combines an HTML template, CSS styles, and a TypeScript class with the @Component decorator. This architecture enables creating reusable and modular interfaces, promoting separation of concerns between the view and business logic.

2

Which syntax displays a TypeScript variable in the template?

Answer

Interpolation with double curly braces {{ variable }} inserts dynamic values into the HTML template. Angular evaluates the TypeScript expression and converts the result to a string displayed in the DOM. This syntax is used to display component properties, perform simple calculations, or call methods that return values.

3

How to bind an HTML property to a component variable?

Answer

Property binding with brackets [property]="variable" binds a DOM element property to a TypeScript expression. Angular evaluates the expression and updates the property automatically when changes occur. This syntax is one-way (component to template) and applies to standard HTML attributes, custom properties, or child component inputs.

4

Which syntax captures a user event in the template?

5

What does the *ngIf directive do in an Angular template?

+17 interview questions

Master Angular for your next interview

Access all questions, flashcards, technical tests, code review exercises and interview simulators.

Start for free