K
K
Konstantin2021-01-25 15:48:27
Angular
Konstantin, 2021-01-25 15:48:27

TreeMaterial Can't bind to 'dataSource' since, what is the reason?

HTML code:

<mat-tree [dataSource]="dataSource" [treeControl]="treeControl" class="example-tree"></mat-tree>


Module:

import { NgModule } from "@angular/core";
import { CommonModule } from "@angular/common";
import { TreeComponent } from "./tree.component";
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
import { BrowserModule } from "@angular/platform-browser";
import { FormsModule } from "@angular/forms";
import { MaterialModule } from "../../material.module";

@NgModule({
  declarations: [TreeComponent],
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    CommonModule,
    FormsModule,
    MaterialModule,
  ],
  exports: [TreeComponent],
})
export class TreeModule {}


I am getting an error in the template:

Can't bind to 'dataSource' since it isn't a known property of 'mat-tree'.
1. If 'mat-tree' is an Angular component and it has 'dataSource' input, then verify that it is part of this module.
2. If 'mat-tree' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question