Templates Flashcards
What is a template reference variable, and how would you use it?
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
What are the possible ways to bind component properties to an associated template?
One Way Data Binding (via interpolation and property binding)
Two Way Data Binding (which combines one way data and event binding)
What’s the difference between binding a value with or without square brackets, i.e.: input attr=”something” vs input [attr]=”something” ?
The square brackets will cause “something” to be evaluated as an expression, as opposed to just be passed in as a literal string
What does the ngFor template syntax look like?
< ul > < li *ngFor=” let val of values “ > {{val}} < /li > < /ul >
What does the pipe syntax look like in Angular templates?
< div> {{ value | my-pipe : option }}< /div>
What does an interpolated string look like in a template?
< div title=” Hello {{username}} “ > … < /div >
What is < ng-container >
A
A grouping element that does not interfere with styles or layout (it’s analogous to curly braces in JavaScript).
What is < ng-template >
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.