首页 > 解决方案 > 从角材料导入树组件

问题描述

我正在尝试导入树组件,即Tree with partially loaded data从材料中导入。我已按照此示例stackblitz

我被这个错误困住了

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

我怎样才能让第一个 matTree(即示例中的蔬菜)默认打开。类似这样的东西。 在此处输入图像描述

标签: angularangular-material

解决方案


您需要添加LoadmoreDatabaseproviders您的ExistingOfferings组件:

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

推荐阅读