ezraroi / ngJsTree

Angular Directive for the famous JS Tree
http://ezraroi.github.io/ngJsTree/
MIT License
270 stars 101 forks source link

Unknown provider: ngJsTreeProvider <- ngJsTree <- ProjectsController #57

Closed jaysig closed 8 years ago

jaysig commented 8 years ago

Hi i'm having an issue getting the directive to load properly. Below is where I am trying to call it and I used bower install and npm install to load it. It show up on my index.html & my app.js.

JS

'use strict';

(function() {

  class ProjectsController {

    constructor($http, $scope, ngJsTree, socket) {
      this.$http = $http;
      this.ngJsTree = ngJsTree;
      this.projects = [];

      $http.get('/api/projects').then(response => {
        this.projects = response.data;
      });

      $scope.$on('$destroy', function() {
        socket.unsyncUpdates('project');
      });
      this.treeData = $scope.projectTree.core.data;
    }
    getProjectFolders(project) {
      this.$http.get('/api/projects/' + project._id + '/folders').then(response => {
        console.log(response.data);
        response.data.forEach( project =>{
          this.treeData.push({'text': project.name});
        });
      });
    }
  }

  angular.module('ScoutIOApp')
    .controller('ProjectsController', ProjectsController);

})();

HTML

<div js-tree="treeConfig" ng-model="projects.projects" tree="projectTree"></div>
ezraroi commented 8 years ago

Please write a plunker that reproduces the problem. You probably didn't add the js tree module to your module dependencies

jaysig commented 8 years ago

For some reason, by grunt building again, it worked without including it in the Controller itself.