axel-zarate / angular-tree-view

Tree view control for AngularJS and Bootstrap
MIT License
24 stars 15 forks source link

Help to newbie in angular #1

Open erezlevi opened 9 years ago

erezlevi commented 9 years ago

Hi, I am trying to add your tree-view into angular tabs I've created inside ng-template but nothing happens. any suggestions ?

mycontroller:

(function() { 'use strict'; var tableCam;

angular.module('app').controller('TabsController', TabsController);

TabsController.$inject = [ 'UserService', '$rootScope' ];
function TabsController(UserService, $rootScope) {
    var vm = this;

//skipped many more functions and other stuff....

vm.structure = { folders : [ { name : 'Folder 1', files : [ { name : 'File 1.jpg' }, { name : 'File 2.png' } ], folders : [ { name : 'Subfolder 1', files : [ { name : 'Subfile 1' } ] }, { name : 'Subfolder 2' }, { name : 'Subfolder 3' } ] }, { name : 'Folder 2' } ] };

        vm.options = {
            onNodeSelect : function(node, breadcrums) {
                vm.breadcrums = breadcrums;
            }
        };

}

})();

axel-zarate commented 9 years ago

Hello, The first thing I see is that you're adding the properties to the controller itself, not the scope. In fact, you're not even injecting the scope into the controller. You would need to change a few things:

TabsController.$inject = [ 'UserService', '$rootScope', '$scope' ];
function TabsController(UserService, $rootScope, $scope) {
    $scope.structure = {
        // All your files and folders
    };
    $scope.options = {
        onNodeSelect : function(node, breadcrums) {
            $scope.breadcrums = breadcrums;
        }
    };
    // The rest of your code
}

I ignore if you're using that $rootScope in the omitted code or if you mistook it for $scope.

erezlevi commented 9 years ago

I've injected the scope and still no luck : the functions are there. its like it doens't work inside text/ng-temlpate noluck

axel-zarate commented 9 years ago

I wouldn't know where the error is. Can you create a JS fiddle and share the link?

erezlevi commented 9 years ago

Hi, thanks for your help. I've solved it forgot to add the module: but my issue now is that I also use Angular Tabs that also use ul/li. see image. angulartree