Angular Forms Flashcards

1
Q

NgForm directive is added automatically by angular and it is

A

internal to angular. We never should set it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What #form=”ngForm” gives us ?

A

access to the NgForm object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

ngModel directive should be placed on

A

every field that we want angular to know about

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Two-way data binding

A

is banana in a box [(ngModel)]=”userSettings.name”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Spread operator …this.originalUserSettings (…) makes

A

copy of each property. Creates a copy of top-level properties

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

To do a deep clone use

A

Lodash in angular.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Using NgForm directive is done by

A

form=”ngForm”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

ngModel build the

A

form.value object. Name attribute is required.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

ng-untouched, ng-touched

A

Field starts off with the ng-untouched class. When we blur it it goes to ng-touched.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

ng-pristine

A

Field value starts as unmodified.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

ng-dirty means that

A

The field was modified

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

ng-valid, ng-invalid.

A

If value is valid, class will be ng-valid. If is invalid, class is ng-invalid.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

the NgModel object has the propertyies like the CSS values for validation

A

untouched, touched, pristine, dirty, valid, invalid

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

To add class conditionally

A
bind to [class.field-error]="form.sbumitted & nameField.invalid" where
.field-error is a class with error styling and 
nameField is property holding the ngModel of the name field.

form is property holding the ngForm

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Blur event is called by

A

(blur)=”onBlur(nameField)” in html and in ts

onBlur(field: NgModel) {
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What to do in order to get an observable to start working?

A

Call it’s subscribe method.

17
Q

The “async” pipe (*ngFor=”let type of subscriptionTypes | async”) will

A

wait until the observable has gotten its data is completed until it builds up our element. In this way if we are waiting for items to load asynchronously we won’t get any template errors. As soon as items resolves, our element will be updated.

18
Q

Check out angular.io/resources for different UI angular components

A