[{"id":"angularbeginner-001","courseId":"angular-beginner","domain":"components-and-templates","topic":"Standalone components and imports","prompt":"In Angular 20, you create a component and leave out the standalone option. How can another component use it in its template?","hint":"Think about what kind of value the imports array of a component expects.","explain":"A component appears in another template only if the consuming component can access it. Whether components stand alone or live in an NgModule depends on the Angular version.","source":"https://angular.dev/guide/components","interaction":{"type":"single"},"options":[{"id":"a","text":"Add the component class to the imports array of the component whose template uses it.","why":"Components are standalone by default, so the class can go straight into another component's imports array."},{"id":"b","text":"Add its selector string, such as 'profile-photo', to the imports array.","whyNot":"The imports array takes the component class; the selector is only used to write the element in a template."},{"id":"c","text":"Declare it in an NgModule's declarations array, then import that module.","whyNot":"That is the older NgModule setup, used by components that set standalone: false."},{"id":"d","text":"Add it to the providers array of the component that uses it.","whyNot":"Providers register services for dependency injection, so they do not make a component appear in a template."}],"answer":"a","explanation":"Components are standalone by default, so a component class can be added directly to another component's imports array.","concept":"Components are standalone by default, so a component class can be added directly to another component's imports array.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["Put the component class, not its selector, in the imports array."]},{"id":"angularbeginner-002","courseId":"angular-beginner","domain":"components-and-templates","topic":"Component selectors and host elements","prompt":"In Angular, the DOM element that matches a component's selector is called its host element, and the component's template renders inside that host element.","hint":"Think about where the component's template ends up in the page.","explain":"A component is shown by writing an element that matches its selector in another component's template. Angular creates one instance of the component for each such element it finds.","source":"https://angular.dev/guide/components","interaction":{"type":"true-false"},"options":[{"id":"a","text":"True","why":"The element matching the selector is the host element, and the template's contents render inside it."},{"id":"b","text":"False","whyNot":"The page says the matched element is the host element and the template's contents render inside it, so the statement is not false."}],"answer":"a","explanation":"The element matching a component's selector is its host element, and the component's template renders inside that element.","concept":"The element matching a component's selector is its host element, and the component's template renders inside that element.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["The element matching a component's selector is its host element; the template renders inside it."]},{"id":"angularbeginner-003","courseId":"angular-beginner","domain":"components-and-templates","topic":"Property binding and interpolation","prompt":"A template has the binding below, and listRole() returns null. What does Angular do with the role attribute?","hint":"Consider what Angular does with an attribute binding that has no value.","explain":"Square brackets with attr. bind HTML attributes that have no matching DOM property, such as SVG attributes. Angular re-applies the binding each time the bound value changes.","source":"https://angular.dev/guide/templates/binding","interaction":{"type":"single"},"options":[{"id":"a","text":"Angular removes the role attribute from the ul element.","why":"A null value in an attribute binding makes Angular remove that attribute."},{"id":"b","text":"Angular sets the role attribute to the text 'null'.","whyNot":"Angular does not write the string 'null'; a null value removes the attribute."},{"id":"c","text":"Angular keeps whatever role value the element had before.","whyNot":"A null value is not ignored; the binding clears the attribute."},{"id":"d","text":"Angular throws an error during rendering.","whyNot":"Null is a valid value for an attribute binding, so no error is raised."}],"answer":"a","explanation":"An attr. binding writes an HTML attribute, and when the bound value is null, Angular removes that attribute.","concept":"An attr. binding writes an HTML attribute, and when the bound value is null, Angular removes that attribute.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","code":"<ul [attr.role]=\"listRole()\"></ul>","takeaways":["Use [attr.name] for attributes with no DOM property; null removes them."]},{"id":"angularbeginner-004","courseId":"angular-beginner","domain":"components-and-templates","topic":"Class and style bindings","prompt":"A component has sectionClasses = signal(['expandable', 'elevated']). Which TWO statements about these bindings are correct?","hint":"Think about how Angular decides that a bound class value has changed.","explain":"A class binding can switch one class on and off, or set a whole list of classes at once. Angular checks whether a bound class value has changed by its reference, not by its contents.","source":"https://angular.dev/guide/templates/binding","interaction":{"type":"multiple","tellCount":true},"options":[{"id":"a","text":"Calling push on the existing array is enough for Angular to update the classes.","whyNot":"Angular compares the binding's reference, so changing the same array in place is not seen as an update."},{"id":"b","text":"When isExpanded() is truthy, Angular adds the expanded class; when falsy, it removes it.","why":"A class binding adds or removes one class based on whether the bound value is truthy or falsy."},{"id":"c","text":"A key such as 'full width' in an object binding applies both classes.","whyNot":"Class bindings do not support space-separated class names in a single key."},{"id":"d","text":"Replacing sectionClasses with a new array makes Angular apply the change.","why":"Angular compares class values with ===, so a new array instance is what triggers an update."},{"id":"e","text":"Angular applies any string bound with [class], even if it is not a valid class name.","whyNot":"Angular ignores string values that are not valid CSS class names."},{"id":"f","text":"Angular guarantees the classes appear in the order the array lists them.","whyNot":"The page says Angular does not guarantee any specific order of CSS classes on rendered elements."}],"answer":"bd","explanation":"Class bindings toggle one class by truthiness, and Angular compares array or object values by reference, so you must replace them to update.","concept":"Class bindings toggle one class by truthiness, and Angular compares array or object values by reference, so you must replace them to update.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","code":"<ul [class.expanded]=\"isExpanded()\"></ul>\n<p [class]=\"sectionClasses()\"></p>","takeaways":["Replace an array or object bound to class instead of mutating it."]},{"id":"angularbeginner-005","courseId":"angular-beginner","domain":"components-and-templates","topic":"Event binding with $event","prompt":"A teammate writes the listener below on an input. What does $event hold inside the template?","hint":"Consider what the browser passes along when the keyup event fires.","explain":"Template listeners run a statement when the DOM emits an event. Inside that statement, a special variable carries information about the event that just happened.","source":"https://angular.dev/guide/templates/event-listeners","interaction":{"type":"single"},"options":[{"id":"a","text":"A reference to the native event object, such as a KeyboardEvent.","why":"Angular provides $event in every template listener, and it holds the browser's event object."},{"id":"b","text":"The text currently typed into the input.","whyNot":"$event is the event object, not the input's value."},{"id":"c","text":"Only the pressed key's name, such as 'Enter'.","whyNot":"The key name is one property of the event object; $event holds the whole object."},{"id":"d","text":"The component instance that owns the template.","whyNot":"$event is the event the browser fired, not the component."}],"answer":"a","explanation":"Angular exposes the native event as $event in every template event listener, so the handler can read its properties.","concept":"Angular exposes the native event as $event in every template event listener, so the handler can read its properties.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","code":"<input (keyup)=\"updateField($event)\" />","takeaways":["Use $event to read details of an event, such as the key that was pressed."]}]