import { CommonModule } from '@angular/common';
import { HttpClient, HttpClientModule } from '@angular/common/http';
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { AuthGuard } from './shared';
import { CookieService} from 'ngx-cookie-service';
import {SelectModule} from 'ng-select';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { ReactiveFormsModule } from '@angular/forms';
import {ToastrModule} from 'ngx-toastr';
//import { TreeComponent } from './tree/tree.component';
import { MatTreeModule, MatIconModule, MatButtonModule } from '@angular/material';
// AoT requires an exported function for factories
export const createTranslateLoader = (http: HttpClient) => {
/* for development
return new TranslateHttpLoader(
http,
'/start-angular/SB-Admin-BS4-Angular-6/master/dist/assets/i18n/',
'.json'
); */
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
};
@NgModule({
imports: [
CommonModule,
BrowserModule,
BrowserAnimationsModule,
HttpClientModule,
NgbModule.forRoot(),
// NgMultiSelectDropDownModule.forRoot(),
// NgSelectModule,
// FormsModule,
SelectModule,
ToastrModule.forRoot(),
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: createTranslateLoader,
deps: [HttpClient]
}
}),
AppRoutingModule,
ReactiveFormsModule,
MatTreeModule,
MatIconModule,
MatButtonModule
],
declarations: [AppComponent],
providers: [AuthGuard, CookieService],
bootstrap: [AppComponent]
})
export class AppModule {}
.example-tree-invisible {
display: none;
}
.example-tree ul,
.example-tree li {
margin-top: 0;
margin-bottom: 0;
list-style-type: none;
}
<mat-tree [dataSource]="nestedDataSource" [treeControl]="nestedTreeControl" class="example-tree">
<mat-tree-node *matTreeNodeDef="let node" matTreeNodeToggle>
<li class="mat-tree-node">
<button mat-icon-button disabled></button>
{{node.filename}}: {{node.type}}
</li>
</mat-tree-node>
<mat-nested-tree-node *matTreeNodeDef="let node; when: hasNestedChild">
<li>
<div class="mat-tree-node">
<button mat-icon-button matTreeNodeToggle
[attr.aria-label]="'toggle ' + node.filename">
<mat-icon class="mat-icon-rtl-mirror">
{{nestedTreeControl.isExpanded(node) ? 'expand_more' : 'chevron_right'}}
</mat-icon>
</button>
{{node.filename}}
</div>
<ul [class.example-tree-invisible]="!nestedTreeControl.isExpanded(node)">
<ng-container matTreeNodeOutlet></ng-container>
</ul>
</li>
</mat-nested-tree-node>
</mat-tree>
感谢您提前帮助我。
我在Angular JS 6中的biggener需要您的帮助,因为我已尝试将树实现到此应用程序链接中,如下所示:-
https://material.angular.io/components/tree/overview
在实施过程中遇到问题时,任何人都可以帮助我摆脱该错误。完成检查元素后,请在浏览器中找到附加的错误日志。
{错误错误:“未捕获(承诺):错误:模块'TreeModule'声明了意外的值'TreeComponent'。请添加@ Pipe / @ Directive / @ Component批注。 语法错误}
如果您需要其他任何检查问题的信息,请告诉我。
谢谢您的回答。