Angular Material TreeTable Component 使用教程
一. 安装
npm i ng-material-treetable --save
npm i @angular/material @angular/cdk @angular/animations --save
二、配置
- 在app.module.ts中导入模块
import { TreetableModule } from 'ng-material-treetable';
@NgModule({
...
imports: [
...
TreetableModule
],
...
})
export class AppModule { }
- 在template中使用,本文使用app.componet.html
<treetable [tree]="arrayOfPerson(yourTreeDataStructure)"></treetable>
- 导入material的样式,在style.css添加
@import url('https://fonts.googleapis.com/css?family=Roboto:400,700|Material+Icons');
- 在app下新建一个yourDataStructure.ts定义自己的数据结构,本文新建Person.ts
import { Node } from 'ng-material-treetable';
export interface Person {
name: string;
age: number;
married: boolean;
}
- 在对应componet中定义自己的树形数据结构
import { Person} from './Person';
import { Node } from 'ng-material-treetable';
export class AppComponent {
…
arrayOfPerson : Node<Person>[]= [
{
value: {
name: 'Marry',
age: 40,
married: true
},
children: [
{
value: {
name: 'Morry',
age: 2,
married: false
},
children: []
},
{
value: {
name: 'Bob',
age: 22,
married: true
},
children: [
{
value: {
name: 'By',
age: 1,
married: false
},
children: []
}
]
}
]
},
{
value: {
name: 'Gray',
age: 30,
married: true
},
children: [
{
value: {
name: 'Gorry',
age: 4,
married: false
},
children: []
},
{
value: {
name: 'Gob',
age: 15,
married: false
},
children: []
}
]
}
]
}
三、查看效果
Ng serve查看效果

参考 <https://www.npmjs.com/package/ng-material-treetable>
Angular Material TreeTable Component 使用教程的更多相关文章
- Angular 2 to Angular 4 with Angular Material UI Components
Download Source - 955.2 KB Content Part 1: Angular2 Setup in Visual Studio 2017, Basic CRUD applicat ...
- Angular Material 教程之布局篇
Angular Material 教程之布局篇 (一) : 布局简介https://segmentfault.com/a/1190000007215707 Angular Material 教程之布局 ...
- Material使用11 核心模块和共享模块、 如何使用@angular/material
1 创建项目 1.1 版本说明 1.2 创建模块 1.2.1 核心模块 该模块只加载一次,主要存放一些核心的组件及服务 ng g m core 1.2.1.1 创建一些核心组件 页眉组件:header ...
- Angular Material design设计
官网: https://material.io/design/ https://meterial.io/components 优秀的Meterial design站点: http://material ...
- [转]VS Code 扩展 Angular 6 Snippets - TypeScript, Html, Angular Material, ngRx, RxJS & Flex Layout
本文转自:https://marketplace.visualstudio.com/items?itemName=Mikael.Angular-BeastCode VSCode Angular Typ ...
- Angular Material Starter App
介绍 Material Design反映了Google基于Android 5.0 Lollipop操作系统的原生应用UI开发理念,而AngularJS还发起了一个Angular Material ...
- Angular Material & Hello World
前言 Angular Material(下称Material)的组件样式至少是可以满足一般的个人开发需求(我真是毫无设计天赋),也是Angular官方推荐的组件.我们通过用这个UI库来快速实现自己的i ...
- angular material dialog应用
1. 打开弹窗的点击事件 project.component.html <button mat-icon-button class="action-button" (clic ...
- Ng-Matero:基于 Angular Material 搭建的中后台管理框架
前言 目前市面上关于 Angular Material 的后台框架比较少,大多都是收费主题,而且都不太好用. 很多人都说 Material 是一个面向 C 端的框架,其实在使用其它框架做管理系统的时候 ...
- 安装 Angular Material UI
文档 调色板 安装 ng add @angular/material ? Choose a prebuilt theme name, or "custom" for a custo ...
随机推荐
- nginx ip段限制
deny 123.0.0.0/8; // 封 123.0.0.1~123.255.255.254 这个段的ip deny 123.1.0.0/16; // 封 123.1.0.1~123.1.255. ...
- vue组件之间的传参
vue组件之间传参有三种传参方式'父传子','子传父','非父子组件之间传值' 父传子 父组件 <template> <CounterCom :num="5"&g ...
- 【awk】找出两个文件中的不同值
https://blog.csdn.net/weixin_33534991/article/details/116683524 awk 'NR==FNR{a[$0]}NR>FNR{ if(!($ ...
- c++ 继承访问控制初步
访问控制方式这里有篇很好的文章,其实内容也是总结c++primer上的内容 现在就按照这篇的文章举例进行学习. 思路 不同继承方式的影响主要体现在: 1.派生类成员对基类成员的访问控制. 2.派生类对 ...
- TypeScript 元组
TypeScript 元组 我们知道数组中元素的数据类型都一般是相同的(any[] 类型的数组可以不同),如果存储的元素数据类型不同,则需要使用元组. 元组中允许存储不同类型的元素,元组可以作为参数传 ...
- Coursera Programming Languages, Part B 华盛顿大学 Week 3
ML Versus Racket 同 函数编程模式 (with constructs that encourage a functional style) 不鼓励 mutation (但提供了支持 m ...
- Unity 简易聊天室(基于TCP)(2)
客户端用Unity开发,主要就是搭建一下聊天室的UI界面:输入框,聊天内容显示框,发送按钮 灰色背景的就是Message,也就是聊天内容的显示框,是一个Text类型,这里创建UI方面就不多讲了 在Ca ...
- 初探AOP
1.背景介绍 1.什么是AOP 1)在OOP(面向对象编程)中,正是这种分散在各处且与对象核心功能无关的代码(横切代码)的存在,使得模块复用难度增加. 2)AOP则将封装好的对象剖开,找出其中对多个 ...
- Peer Review
What are Peng (Bob) Chi's top 3 strengths? Can you give an example of how one or two of those stren ...
- 【LeetCode - 1055】形成字符串的最短路径
1.题目描述 代码: #include <iostream> #include <string> using namespace std; const int MAX_LETT ...