Angular - ComponentsWhich of the following is the correct way to define a component selector as an attribute?Aselector: 'appHighlight'Bselector: '[appHighlight]'Cselector: '.appHighlight'Dselector: '#appHighlight'Check Answer
Step-by-Step SolutionSolution:Step 1: Understand selector syntax for attributesTo use a component as an attribute, the selector must be wrapped in square brackets [].Step 2: Match options to syntaxselector: '[appHighlight]' uses brackets correctly. selector: 'appHighlight' is a tag selector, C is a class selector, D is an ID selector.Final Answer:selector: '[appHighlight]' -> Option BQuick Check:Attribute selector = brackets [] [OK]Quick Trick: Use brackets [] for attribute selectors [OK]Common Mistakes:Forgetting brackets for attribute selectorsConfusing class and ID selectors with component selectors
Master "Components" in Angular9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallPerf
More Angular Quizzes Angular Fundamentals - How Angular bootstraps an application - Quiz 5medium Component Interaction - @ContentChild and content projection - Quiz 2easy Directives - Directive execution and DOM manipulation - Quiz 11easy Lifecycle Hooks - ngDoCheck for custom change detection - Quiz 13medium Lifecycle Hooks - ngOnDestroy for cleanup - Quiz 13medium Pipes - Parameterized pipes - Quiz 12easy Pipes - Parameterized pipes - Quiz 15hard Templates and Data Binding - Two-way binding with ngModel - Quiz 1easy Templates and Data Binding - Interpolation with double curly braces - Quiz 15hard Templates and Data Binding - Why data binding matters - Quiz 11easy