1inus / ng.tree

11 stars 5 forks source link

rename from angular4-tree to ng.tree!

document

live demo

screenshot

screenshot screenshot screenshot screenshot

NPM

npm install ng.tree

Release notes

TODO

Classes & Api

NgTree

ngTree component. useage : <ngTree [treeData]="TreeData[]" [treeConfig]="TreeConfig">

TreeData

data for creating tree

TreeConfig

Usage & demo

talk is cheape, show you my code

step 1

import css

<link rel="stylesheet" href="https://github.com/1inus/ng.tree/blob/master/./node_modules/ng-tree/style/tree.css">

step 2

use it

import {Component, NgModule} from '@angular/core';
import {BrowserModule} from "@angular/platform-browser";
import {platformBrowserDynamic} from "@angular/platform-browser-dynamic";
import {NgTree} from "ng.tree";

@Component({
    selector: 'app',
    template: `<ngTree [treeData]="treeData" [treeConfig]="treeConfig"></ngTree>`
})
export class App {
    public treeData: any[] = [{
        name: "folder",
        isOpen:true,
        iconSelector:"computer",
        nameSelector:"warning",
        nodes: [{
            name: 'file'
        }]
    },{
        name: 'another folder',
        nodes:[{
            name: 'another file'
        }]
    }];

    public treeConfig : any = {
        dataMap:{
            children:"nodes"
        }
    }
}

@NgModule({
    imports: [BrowserModule],
    entryComponents:[NgTree],
    declarations: [NgTree, App],
    bootstrap: [App]
})
export class AppModule {}
platformBrowserDynamic().bootstrapModule(AppModule);