All quizzesEasy
Angular Basics — Series 3
Preview — 3 of 10 questions
What does this template render when user is null?
javascript
<p>{{ user?.name }}</p>AAn empty string — Angular reads user?.name, sees user is null and stops there instead of throwing
BIt throws TypeError: Cannot read properties of null
CIt renders the literal text null
DIt renders undefined
Why does the second line work but the first one fail to compile?
javascript
<td [colspan]="span"></td>
<td [attr.colspan]="span"></td>AThere is no difference; both set the same thing
BThere is no DOM property literally named colspan (the reflected property is colSpan, camelCase), so Angular rejects [colspan] with "Can't bind to 'colspan' since it isn't a known property of 'td'" (NG0303). [attr.colspan] sets the HTML attribute directly and always works
C[colspan] is deprecated syntax
D[attr.colspan] only works inside <table> elements
[(ngModel)]="name" is shorthand for which pair of bindings?
javascript
<input [(ngModel)]="name">A[ngModel]="name" combined with (ngModelChange)="name = $event"
B[value]="name" combined with (input)="name = $event"
CIt is not shorthand for anything — it is a single, atomic directive input
D(ngModel)="name" combined with [ngModelChange]="name"
Sign up free to play
Answer all 10 questions (7 more), see explanations for every answer, and track your score.