Multiple components match node with tagname button

Viewed 2206

I'm build a web app with Angular 11 and Material, and it seems like Material's <button> is confliting with something.

enter image description here

I definitely didn't create a component called button so I can only assume it's conflicting with some other module. Here are my modules:

AppModule:

@NgModule({
  declarations: [AppComponent, LoginComponent, PacienteComponent, AgendaComponent, FinanceiroComponent],
  imports: [
    BrowserModule,
    AppRoutingModule,
    BrowserAnimationsModule,
    SharedModule,
    FormsModule,
    HttpClientModule,
  ],
  providers: [LoginService],
  bootstrap: [AppComponent],
})
export class AppModule {}

SharedModule:

@NgModule({
  declarations: [
    NavBarComponent,
    UserLoginComponent,
    ModalComponent,
    SideMenuComponent,
  ],
  exports: [NavBarComponent, MaterialModule],
  imports: [
    CommonModule,
    MaterialModule
  ],
})
export class SharedModule {}

MaterialModule:

@NgModule({
  imports: [
    MatCardModule,
    MatInputModule,
    MatButtonModule,
    MatProgressSpinnerModule,
    MatCheckboxModule,
    MatDialogModule,
    MatMenuModule,
    MatSidenavModule,
    MatListModule,
    MatToolbarModule,
    MatIconModule,
  ],
  exports: [
    MatCardModule,
    MatInputModule,
    MatButtonModule,
    MatProgressSpinnerModule,
    MatCheckboxModule,
    MatDialogModule,
    MatMenuModule,
    MatSidenavModule,
    MatListModule,
    MatToolbarModule,
    MatIconModule,
  ],
})
export class MaterialModule {}

I only made sure to add all the modules I'm using because I'm pretty sure I'm messing something up here. Commenting out the MatButtonModule on the last modules file makes everything work again, but I kinda need that in.

Thanks!

2 Answers

I'm not sure why, but moving de MatButtonModules import up to AppModules fix it. If someone can explain why this happened, I'll mark it as the answer.

Selector collisions are module scoped. Moving the module import has likely had an effect on the namespace.

Related