从角形材质导入树组件

时间:2018-08-23 06:24:55

标签: angular angular-material

我正在尝试从材料中导入树组件i,e Tree with partially loaded data。根据此示例,我遵循了stackblitz

我被这个错误困扰

ERROR Error: StaticInjectorError(AppModule)[ExistingOfferingsComponent->LoadmoreDatabase]: 
StaticInjectorError(Platform: core)[ExistingOfferingsComponent -> LoadmoreDatabase]: 
NullInjectorError: No provider for LoadmoreDatabase!

我该如何默认使第一个matTree(示例中为蔬菜)处于打开状态。 enter image description here

1 个答案:

答案 0 :(得分:2)

您需要将LoadmoreDatabase添加到providers组件的ExistingOfferings中:

@Component({
    selector: 'existing-offerings-component',
    templateUrl: 'existing-offerings-component.html',
    styleUrls: ['existing-offerings-component.css'],
    providers: [LoadmoreDatabase]
})
export class ExistingOfferingsComponent{
    ...
}