npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

am-js-tree

v1.0.2

Published

Light Angular Component that wraps jsTree library.

Readme

npm version Bower version Dependency Status

am-js-tree

Light Angular Component that wraps jsTree library.

Dependencies

The amJsTree depends on the following libraries:

  • jquery >= 1.9.1
  • angular >= 1.5.x
  • jstree >= 3.3.3 (tested on version 3.3.3 may support older versions as well)

Install

You can install the amJsTree via bower:

bower install am-js-tree --save

or via npm:

npm install am-js-tree --save

or you can add the amJsTree.min.js file to your HTML page:

<script src="jquery.js"/>
<script src="angular-1.5.x.js"/>
<script src="jstree.min.js"/>
<script src="am-js-tree.min.js"/>

Add the amJsTree to your module dependencies


 angular.module('myApp',['amJsTree'])

Documentation

The main purpose for this wrapper is to integrate easily jsTree in your angular application and work with the jsTree api exactly as if you were using the jquery plugin. this wrapper is a very simple component that registers your selected jsTree/jsTree plugins event and attaches them to your controller. NO WATCHERS!

You can find the jsTree documentation at this link

Usage

<am-js-tree config="jsTreeConfig"></am-js-tree>
  • config - This is the configuration object of the jsTree, if you will not supply one, an empty one will be created (not mandatory).

Registering for events

You can register a callback to any Js Tree and plugins event:

  • events - Add the events object and specify the name of the events to register for, And a callback for each event in the following event's format e.g
events: {
    'eventName': cb 
    }
    

The cb function will always contain two arguments:

  • event - the event
  • data - an object that contains all arguments that return from jsTree event

Example:

<am-js-tree config="$ctrl.jsTreeConfig"></am-js-tree>
(function () {
    
  class MyComponent{
    constructor() {
        this.jsTreeConfig = {
          core: {
            check_callback: (operation, node, node_parent, node_position, more) => {
              console.log(operation, node, node_parent, node_position, more);
            }
          },
          events: {
            //like the jsTree api only wrapped in event object
            'init.jstree': (e, data) => {
                console.log(e, data);
            },
            'ready.jstree': (e, data) => {
              console.log(e, data);
            },
            'load_node.jstree': (e, data) => {
                console.log(e, data);
            }
          }
        }
    }
  }


  angular.module('myApp')
    .component('myComponent', {
      controller: [MyComponent]
    });

})();

Using the Js Tree API from your controller

  • jsTree instance is an object that contains the list of events with the callback objects.

Example:

<am-js-tree config="$ctrl.jsTreeConfig"></am-js-tree>
(function () {
    
  class MyComponent{
    constructor() {
        this.jsTreeConfig = {
          core: {
             data: [{"id" : 1, "text" : "Node 1"}, {"id" : 2, "text" : "Node 2"}];
          },
          events: {
             'ready.jstree': (e, data) => {
                  this.jsTreeInstance = data.instance;
             }
          }
        };
        
        //now lets say we want to add more nodes
        //once we have the jsTree instance we can do everything exactly as it appears in the jsTree docs
         this.jsTreeInstance.settings.core.data.push({"id" : 3, "text" : "Node 3"}, {"id" : 4, "text" : "Node 4"});
         this.jsTreeInstance.refresh();
    }
  }


  angular.module('myApp')
    .component('myComponent', {
      controller: [MyComponent]
    });

})();

License

MIT