Bird
0
0

Given this shared module code, what will be the output when FeatureComponent uses SharedButtonComponent?

medium📝 component behavior Q13 of 15
Angular - Modules
Given this shared module code, what will be the output when FeatureComponent uses SharedButtonComponent?
@NgModule({
  declarations: [SharedButtonComponent],
  exports: [SharedButtonComponent]
})
export class SharedModule {}
@NgModule({
  imports: [SharedModule],
  declarations: [FeatureComponent]
})
export class FeatureModule {}
If FeatureComponent template contains <app-shared-button>Click</app-shared-button>, what happens?
AThe button renders correctly with text 'Click'
BError: 'app-shared-button' is not a known element
CThe button renders but without text
DThe app crashes at runtime
Step-by-Step Solution
Solution:
  1. Step 1: Check module imports and exports

    SharedButtonComponent is declared and exported in SharedModule, which is imported by FeatureModule.
  2. Step 2: Confirm component usage in FeatureComponent

    Since FeatureModule imports SharedModule, FeatureComponent can use SharedButtonComponent selector without error.
  3. Final Answer:

    The button renders correctly with text 'Click' -> Option A
  4. Quick Check:

    Imported shared module exports = component usable [OK]
Quick Trick: Import shared module to use its exported components [OK]
Common Mistakes:
  • Not importing SharedModule in FeatureModule
  • Forgetting to export component in SharedModule
  • Using component selector incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes