Bird
0
0

You want to create a shared module that provides a reusable button component and a custom pipe. Which setup correctly allows any feature module to use both without redeclaring them?

hard📝 Application Q15 of 15
Angular - Modules
You want to create a shared module that provides a reusable button component and a custom pipe. Which setup correctly allows any feature module to use both without redeclaring them?
// SharedModule
@NgModule({
  declarations: [SharedButtonComponent, CustomPipe],
  exports: [SharedButtonComponent, CustomPipe],
  imports: [CommonModule]
})
export class SharedModule {}
// FeatureModule
@NgModule({
  imports: [SharedModule],
  declarations: [FeatureComponent]
})
export class FeatureModule {}
What must you do in FeatureComponent template to use both?
AImport SharedButtonComponent and CustomPipe directly in FeatureComponent
BUse <code><app-shared-button></code> and apply <code>| customPipe</code> in template expressions
CDeclare SharedButtonComponent and CustomPipe again in FeatureModule
DUse <code><shared-button></code> and <code>| CustomPipe</code> with capital letters
Step-by-Step Solution
Solution:
  1. Step 1: Confirm shared module exports

    SharedButtonComponent and CustomPipe are declared and exported in SharedModule, which FeatureModule imports.
  2. Step 2: Use correct selectors and pipe names

    FeatureComponent can use selector and apply | customPipe (pipe names are case-sensitive and lowercase by convention).
  3. Final Answer:

    Use <app-shared-button> and apply | customPipe in template expressions -> Option B
  4. Quick Check:

    Import shared module + use selectors and pipe names correctly [OK]
Quick Trick: Use exported selectors and pipe names exactly as declared [OK]
Common Mistakes:
  • Redeclaring shared components or pipes in feature modules
  • Using wrong selector or pipe name casing
  • Trying to import components or pipes directly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes