[{"id":"angularintermediate-001","courseId":"angular-intermediate","domain":"components-and-templates","topic":"Required inputs with input.required","prompt":"A slider component declares value = input.required<number>(). A parent template uses <custom-slider /> without setting value. What does Angular do?","hint":"Compare when Angular checks a required input with when it checks an optional one.","explain":"An input() can be left unset, and then it reads as undefined unless it has a default. input.required() changes what every template that uses the component must do.","source":"https://angular.dev/guide/components/inputs","interaction":{"type":"single"},"options":[{"id":"a","text":"The build reports an error, because a required input must be set wherever the component is used.","why":"Angular enforces required inputs in templates and reports a build-time error when one is missing."},{"id":"b","text":"The build succeeds, and value falls back to 0.","whyNot":"Only input(0) carries a default; input.required() declares no default value."},{"id":"c","text":"The build succeeds, and value is undefined at runtime.","whyNot":"That is how an optional input() without a default behaves; a missing required input is caught at build time first."},{"id":"d","text":"The build succeeds, and value's type becomes number | undefined.","whyNot":"Required inputs do not automatically add undefined to the generic parameter, so the type stays number."}],"answer":"a","explanation":"input.required() declares an input that templates must set; Angular reports a build-time error when it is missing, and the type does not gain undefined.","concept":"input.required() declares an input that templates must set; Angular reports a build-time error when it is missing, and the type does not gain undefined.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","code":"export class CustomSlider {\n  value = input.required<number>();\n}","takeaways":["input.required<T>() turns a missing binding into a build-time error, not an undefined value at runtime."]},{"id":"angularintermediate-002","courseId":"angular-intermediate","domain":"components-and-templates","topic":"Input transforms with booleanAttribute","prompt":"A component declares disabled = input(false, {transform: booleanAttribute}). Which TWO statements about values set on this input in templates are true?","hint":"Think about how a bare HTML attribute is read, and when Angular calls the transform.","explain":"A transform converts a value before the input stores it, and Angular calls it whenever it sets the input. The built-in boolean transform is modeled on HTML attributes, with one difference.","source":"https://angular.dev/guide/components/inputs","interaction":{"type":"multiple","tellCount":true},"options":[{"id":"a","text":"A bare <x-button disabled /> sets disabled to true, as a native HTML boolean attribute would.","why":"booleanAttribute imitates HTML boolean attributes, where the presence of the attribute means true."},{"id":"b","text":"A binding of the literal string 'false', as in <x-button disabled='false' />, sets disabled to false.","why":"Unlike plain HTML, Angular's booleanAttribute treats the literal string 'false' as boolean false."},{"id":"c","text":"<x-button disabled='false' /> still disables the button, because any attribute value counts as present.","whyNot":"The transform reads the literal string 'false' as false, so the input is not set to true."},{"id":"d","text":"The transform runs only once, when the component is created, so later bindings skip it.","whyNot":"Angular runs the transform whenever it sets the input, so each new bound value passes through it."},{"id":"e","text":"A template may choose the transform with an expression, such as transform: isStrict ? a : b.","whyNot":"Transform functions must be statically analyzable; they cannot be picked conditionally or from an expression."},{"id":"f","text":"The transform may read a service's state, since it runs at set time.","whyNot":"Transforms should be pure functions, because relying on outside state leads to unpredictable behavior."}],"answer":"ab","explanation":"booleanAttribute reads presence as true like HTML, but treats the literal string 'false' as false; transforms run whenever Angular sets the input.","concept":"booleanAttribute reads presence as true like HTML, but treats the literal string 'false' as false; transforms run whenever Angular sets the input.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","code":"disabled = input(false, {\n  transform: booleanAttribute,\n});","takeaways":["booleanAttribute: a bare attribute means true, and the string 'false' means false.","Transform functions run on every set and should be pure."]},{"id":"angularintermediate-003","courseId":"angular-intermediate","domain":"components-and-templates","topic":"Output events with output()","prompt":"A <custom-slider> emits valueChanged through an output(). Because the event comes from that element, a listener on a wrapping <div> also receives it as the event bubbles up the DOM.","hint":"Compare a component's custom event with a native browser event such as click.","explain":"An output lets a component raise its own events, similar to native events such as click. Consider whether a custom event travels up the element tree the way a native click does.","source":"https://angular.dev/guide/components/outputs","interaction":{"type":"true-false"},"options":[{"id":"a","text":"True","whyNot":"Custom output events do not bubble up the DOM, so the wrapping div's listener never sees them."},{"id":"b","text":"False","why":"Angular custom events do not bubble up the DOM, so a wrapping element's listener does not receive them."}],"answer":"b","explanation":"Angular custom events raised through output() do not bubble up the DOM.","concept":"Angular custom events raised through output() do not bubble up the DOM.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["Angular custom events do not bubble, so ancestors cannot catch them with a listener."]},{"id":"angularintermediate-004","courseId":"angular-intermediate","domain":"components-and-templates","topic":"Model inputs for two-way binding","prompt":"A child component declares count = model<number>(0) and calls this.count.update(...) to change it. The parent has initialCount = 18. Which template binding lets those writes update initialCount?","hint":"Consider which binding carries values in both directions, not just one.","explain":"Some bindings only pass a value into a property, while model inputs let the component write back. The parent must pick the binding form that carries those writes back.","source":"https://angular.dev/guide/templates/two-way-binding","interaction":{"type":"single"},"options":[{"id":"a","text":"<app-counter [(count)]=\"initialCount\" />","why":"The two-way binding syntax [()] propagates the child's new values back to initialCount."},{"id":"b","text":"<app-counter [count]=\"initialCount\" />","whyNot":"A plain property binding only binds a value into the property; it has no way to send writes back."},{"id":"c","text":"<app-counter (count)=\"initialCount\" />","whyNot":"Parentheses alone are event binding, which listens for an event named count, not a two-way link."},{"id":"d","text":"<app-counter count=\"initialCount\" />","whyNot":"A plain attribute passes the literal text initialCount, not the value of the parent's property."}],"answer":"a","explanation":"A model input lets the component write values back, and a two-way [()] binding propagates those new values to the parent's property or signal.","concept":"A model input lets the component write values back, and a two-way [()] binding propagates those new values to the parent's property or signal.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","code":"export class Counter {\n  count = model<number>(0);\n}","takeaways":["Use [(name)] when a child writes to a model input; a plain [name] binding only sends values down."]},{"id":"angularintermediate-005","courseId":"angular-intermediate","domain":"components-and-templates","topic":"Content projection with select","prompt":"A card's template has <ng-content select=\"card-title\" /> and a divider, but no bare <ng-content />. A parent writes <custom-card><card-title>Hello</card-title><p>Welcome</p></custom-card>. What renders?","hint":"Consider what happens to projected content that matches none of the placeholders.","explain":"Content projection places a parent's child elements into slots in a component's template. A select on ng-content claims only matching elements, so your slots decide what else shows.","source":"https://angular.dev/guide/components/content-projection","interaction":{"type":"single"},"options":[{"id":"a","text":"Only the card-title renders; the paragraph is not rendered into the DOM.","why":"Without a placeholder that has no select, elements that match no placeholder do not render."},{"id":"b","text":"Both render, with the paragraph appended after the component's template.","whyNot":"Unmatched content is not appended; it only renders where a bare ng-content placeholder exists."},{"id":"c","text":"Angular reports a build error, because the paragraph has no matching slot.","whyNot":"Unmatched content is not rejected; it simply does not appear in the rendered DOM."},{"id":"d","text":"Both render, because select only controls the order, not which elements show.","whyNot":"select decides which content a placeholder claims, and content no placeholder claims is not shown."}],"answer":"a","explanation":"An ng-content with select claims only matching projected elements; if no ng-content lacks a select, unmatched elements do not render into the DOM.","concept":"An ng-content with select claims only matching projected elements; if no ng-content lacks a select, unmatched elements do not render into the DOM.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["Without a bare <ng-content />, projected elements that match no select are not rendered."]}]