Q. Which module is used for template-driven forms in Angular?

  • (A) ReactiveFormsModule
  • (B) FormsModule
  • (C) HttpClientModule
  • (D) BrowserModule
πŸ’¬ Discuss
βœ… Correct Answer: (B) FormsModule
Explanation: FormsModule is used to work with template-driven forms in Angular.

Q. What directive is used to bind a form control in template-driven forms?

  • (A) formControlName
  • (B) ngForm
  • (C) ngModel
  • (D) ngSubmit
πŸ’¬ Discuss
βœ… Correct Answer: (C) ngModel
Explanation: ngModel binds an input field to a model in template-driven forms.

Q. Which class represents a form group in reactive forms?

  • (A) FormArray
  • (B) FormBuilder
  • (C) FormControl
  • (D) FormGroup
πŸ’¬ Discuss
βœ… Correct Answer: (D) FormGroup
Explanation: FormGroup represents a group of FormControl instances in reactive forms.

Q. How do you apply built-in validators in reactive forms?

  • (A) Directives
  • (B) Validators class
  • (C) ngModel
  • (D) FormArray
πŸ’¬ Discuss
βœ… Correct Answer: (B) Validators class
Explanation: Angular provides the Validators class to apply built-in validation rules.

Q. What is the purpose of the 'asyncValidator' in Angular forms?

  • (A) Validate on the client side only
  • (B) Perform asynchronous validations like checking availability from API
  • (C) Track form status
  • (D) Reset form values
πŸ’¬ Discuss
βœ… Correct Answer: (B) Perform asynchronous validations like checking availability from API
Explanation: asyncValidator performs server-side or delayed validations asynchronously.

Q. What does the 'pristine' property of a form control indicate?

  • (A) The control has validation errors
  • (B) The control value has been changed
  • (C) The control has never been modified
  • (D) The control is invalid
πŸ’¬ Discuss
βœ… Correct Answer: (C) The control has never been modified
Explanation: 'pristine' means the user has not interacted with the input.

Q. Which module is needed to use Angular Material components?

  • (A) MaterialComponentsModule
  • (B) MatModule
  • (C) AngularMaterialModule
  • (D) MatInputModule and others individually
πŸ’¬ Discuss
βœ… Correct Answer: (D) MatInputModule and others individually
Explanation: Angular Material modules are imported individually like MatInputModule, MatButtonModule, etc.

Q. Which component in Angular Material is used for dialogs?

  • (A) MatFormField
  • (B) MatDialog
  • (C) MatSnackBar
  • (D) MatTable
πŸ’¬ Discuss
βœ… Correct Answer: (B) MatDialog
Explanation: MatDialog is used to create modal dialog windows in Angular Material.

Q. What command is used to add Angular Material to a project?

  • (A) ng material install
  • (B) ng add @angular/material
  • (C) npm install angular-material
  • (D) material init
πŸ’¬ Discuss
βœ… Correct Answer: (B) ng add @angular/material
Explanation: Angular CLI provides `ng add @angular/material` to install and configure Angular Material.

Q. Which Angular feature allows creating components without a module?

  • (A) Ivy Engine
  • (B) Standalone components
  • (C) Dynamic imports
  • (D) Zone.js
πŸ’¬ Discuss
βœ… Correct Answer: (B) Standalone components
Explanation: Standalone components can work without being declared in an NgModule.