0
0
Angularframework~10 mins

Two-way binding with ngModel in Angular - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to bind the input value to the component property using ngModel.

Angular
<input type="text" [(ngModel)]="[1]">
Drag options to blanks, or click blank then click option'
Avalue
Bdata
CinputValue
Dusername
Attempts:
3 left
💡 Hint
Common Mistakes
Using only [ngModel] or (ngModel) instead of [(ngModel)]
Binding to a property name that does not exist in the component
2fill in blank
medium

Complete the code to import the module needed for ngModel to work.

Angular
import { [1] } from '@angular/forms';
Drag options to blanks, or click blank then click option'
AFormsModule
BFormControlModule
CReactiveFormsModule
DNgModelModule
Attempts:
3 left
💡 Hint
Common Mistakes
Importing ReactiveFormsModule instead of FormsModule
Forgetting to import any forms module
3fill in blank
hard

Fix the error in the code to correctly bind the input to the property 'email'.

Angular
<input type="email" [1]="email">
Drag options to blanks, or click blank then click option'
A[(ngModel)]
B[ngModel]
C(ngModel)
DngModel
Attempts:
3 left
💡 Hint
Common Mistakes
Using only [ngModel] or (ngModel) instead of [(ngModel)]
Missing the parentheses or brackets
4fill in blank
hard

Fill both blanks to create a two-way binding for the property 'age' in the input element.

Angular
<input type="number" [1]="[2]">
Drag options to blanks, or click blank then click option'
A[(ngModel)]
B[ngModel]
Cage
DuserAge
Attempts:
3 left
💡 Hint
Common Mistakes
Using [ngModel] instead of [(ngModel)] for two-way binding
Binding to a property name that does not exist
5fill in blank
hard

Fill all three blanks to bind the input to 'password', import the correct module, and add the module to imports array.

Angular
import { [1] } from '@angular/forms';

@NgModule({
  imports: [[2]],
})
export class AppModule {}

// In template:
<input type="password" [3]="password">
Drag options to blanks, or click blank then click option'
AFormsModule
C[(ngModel)]
DReactiveFormsModule
Attempts:
3 left
💡 Hint
Common Mistakes
Importing ReactiveFormsModule instead of FormsModule
Forgetting to add FormsModule to imports array
Using [ngModel] or (ngModel) instead of [(ngModel)]