Templates Flashcards

1
Q

What is a template reference variable, and how would you use it?

A

A variable (defined using a #) in a component template, which can be referenced in other parts of the template
For example, a template variable for a form can then be referenced by other elements of the form

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

What are the possible ways to bind component properties to an associated template?

A

One Way Data Binding (via interpolation and property binding)
Two Way Data Binding (which combines one way data and event binding)

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

What’s the difference between binding a value with or without square brackets, i.e.: input attr=”something” vs input [attr]=”something” ?

A

The square brackets will cause “something” to be evaluated as an expression, as opposed to just be passed in as a literal string

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

What does the ngFor template syntax look like?

A

< ul > < li *ngFor=” let val of values “ > {{val}} < /li > < /ul >

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

What does the pipe syntax look like in Angular templates?

A

< div> {{ value | my-pipe : option }}< /div>

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

What does an interpolated string look like in a template?

A

< div title=” Hello {{username}} “ > … < /div >

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

What is < ng-container >

A

A
A grouping element that does not interfere with styles or layout (it’s analogous to curly braces in JavaScript).

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

What is < ng-template >

A

It’s an Angular element for rendering HTML when using structural directives. The ng-template itself does not render to anything but a comment directly.

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