All featured quizzes

Angular - Basics

Component decorators, selectors, Angular maintainer, RxJS Observables, dependency injection, and HttpClient.

Sample Questions

A preview of what's in this quiz. Answer them interactively for instant scoring and full explanations.

What is Angular?

1. What is Angular?

  • A.A lightweight CSS template styling library
  • B.A database query tool for MongoDB servers
  • C.A TypeScript-based framework for building web applications, developed by Google
  • D.A runtime compiler for native iOS and Android apps only
Which company is the primary developer and maintainer of Angular?

2. Which company is the primary developer and maintainer of Angular?

  • A.Meta (Facebook)
  • B.Microsoft
  • C.Google
  • D.Amazon
Which Angular CLI command starts the local development server and watches for changes?

3. Which Angular CLI command starts the local development server and watches for changes?

  • A.ng start
  • B.ng dev
  • C.ng serve
  • D.ng run
What are the three most common metadata properties configured inside the `@Component` decorator?

4. What are the three most common metadata properties configured inside the `@Component` decorator?

  • A.name, route, and components
  • B.tag, html, and css
  • C.selector, templateUrl, and styleUrls
  • D.imports, declarations, and providers
What is the template syntax for text interpolation (rendering TypeScript variable values in the HTML)?

5. What is the template syntax for text interpolation (rendering TypeScript variable values in the HTML)?

  • A.[expression]
  • B.(expression)
  • C.{{ expression }}
  • D.${expression}
What is the command to generate a new component named 'user-profile' in the Angular CLI?

6. What is the command to generate a new component named 'user-profile' in the Angular CLI?

  • A.ng create component user-profile
  • B.ng new component user-profile
  • C.ng generate component user-profile
  • D.ng add component user-profile
What are 'Standalone Components' in Angular (introduced in Angular 14)?

7. What are 'Standalone Components' in Angular (introduced in Angular 14)?

  • A.Components that only run on backend Node.js servers
  • B.Components that do not use any CSS stylesheets
  • C.Components that do not require declaration in an NgModule, simplifying app structure
  • D.Components that run in a separate browser thread
Which Angular CLI command compiles the application into a production build directory?

8. Which Angular CLI command compiles the application into a production build directory?

  • A.ng compile
  • B.ng package
  • C.ng build
  • D.ng publish
Which decorator is used to define an Angular Module class, grouping components, directives, and services?

9. Which decorator is used to define an Angular Module class, grouping components, directives, and services?

  • A.@Component
  • B.@Module
  • C.@NgModule
  • D.@Injectable
Which decorator must be added to a TypeScript class to define it as an Angular Component?

10. Which decorator must be added to a TypeScript class to define it as an Angular Component?

  • A.@Directive
  • B.@Injectable
  • C.@Component
  • D.@NgModule
What is the name of the Angular Command Line Interface tool?

11. What is the name of the Angular Command Line Interface tool?

  • A.Angular CLI (ag)
  • B.Angular CLI (cli)
  • C.Angular CLI (ng)
  • D.Angular Tool (angular)
What does a 'structural directive' do in Angular templates?

12. What does a 'structural directive' do in Angular templates?

  • A.It modifies the visual appearance (like background color) of an existing element.
  • B.It imports external JavaScript files dynamically.
  • C.It alters the DOM layout structure by adding, removing, or replacing elements.
  • D.It registers routing configurations inside components.
What does an 'attribute directive' do in Angular templates?

13. What does an 'attribute directive' do in Angular templates?

  • A.It adds or destroys elements in the DOM tree.
  • B.It declares route paths inside layout templates.
  • C.It modifies the appearance or behavior of an existing element without changing the DOM structure.
  • D.It handles database operations inside components.
What is the purpose of the `trackBy` function when using the `*ngFor` directive?

14. What is the purpose of the `trackBy` function when using the `*ngFor` directive?

  • A.To sort the list items in alphabetical order
  • B.To bind click event handlers to each listed item
  • C.To optimize list rendering performance by tracking items based on unique identifiers
  • D.To automatically apply CSS styles to alternate list rows
Which built-in structural directive is used to render a list of items from an array in Angular templates?

15. Which built-in structural directive is used to render a list of items from an array in Angular templates?

  • A.*ngIf
  • B.*ngLoop
  • C.*ngFor
  • D.*ngRepeat
Which directive and syntax are used to implement two-way data binding in Angular?

16. Which directive and syntax are used to implement two-way data binding in Angular?

  • A.[ngModel]="variable"
  • B.(ngModel)="variable"
  • C.[(ngModel)]="variable"
  • D.{{ngModel}}="variable"
Which syntax is used for property binding (passing data from the component class to an HTML attribute)?

17. Which syntax is used for property binding (passing data from the component class to an HTML attribute)?

  • A.(property)="value"
  • B.{{property}}="value"
  • C.[property]="value"
  • D.[[property]]="value"
What character is used as a prefix to identify a structural directive in Angular templates?

18. What character is used as a prefix to identify a structural directive in Angular templates?

  • A.A pound sign (#)
  • B.An at sign (@)
  • C.An asterisk (*)
  • D.A dollar sign ($)
Which Angular module must be imported in your module/component to enable the use of the `[(ngModel)]` directive?

19. Which Angular module must be imported in your module/component to enable the use of the `[(ngModel)]` directive?

  • A.CommonModule
  • B.ReactiveFormsModule
  • C.FormsModule
  • D.HttpModule
What is the correct syntax for using `*ngFor` to iterate over an array of `users`?

20. What is the correct syntax for using `*ngFor` to iterate over an array of `users`?

  • A.*ngFor="user in users"
  • B.*ngFor="let user in users"
  • C.*ngFor="let user of users"
  • D.*ngFor="user of users"

Looking for a different topic? Browse all subjects