Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'childrenProperty' of undefined #3

Open
mikeddol opened this issue Aug 1, 2017 · 1 comment
Open

Cannot read property 'childrenProperty' of undefined #3

mikeddol opened this issue Aug 1, 2017 · 1 comment

Comments

@mikeddol
Copy link

mikeddol commented Aug 1, 2017

I have installed your module using bower, did all the correct linking into the project. Then added your module as a dependency in my module and used it in a component.
The component looks something like this:

(function () {
    angular.module('tree-dropdown', [
        'angularjsDropdownTree'
    ]);

    angular.module('tree-dropdown').component('treeDropdown', {
        templateUrl: 'some-place/tree-dropdown/tree-dropdown.tpl.html',
        controller: 'TreeDropdownController',
        bindings: {
            options: '<',
            change: '&'
        }
    });

    angular.module('tree-dropdown').controller('TreeDropdownController', TreeDropdownController);

    TreeDropdownController.$inject = [];
    function TreeDropdownController() {
        var ctrl = this;

        ctrl.settings = {
            selectionLimit: 1,
            childrenProperty: 'theChild',
            disableSearch: true,
            subProperty: 'theChild'
        };

        ctrl.onSelected = function (selection) {

        };
    }
})();

The template looks like this:
<dropdown-tree selection-changed="$ctrl.onSelected(selection)" options="$ctrl.thing" settings="$ctrl.settings"></dropdown-tree>

The data coming through the options binding comes through and looks something like this:

[
    {name: 'a', uuid: 1, theChild: []
    },
    {name:'b', uuid: 2, theChild: [
            {name:'c', uuid: 3, theChild: []
            },
            {name:'d', uuid: 4, theChild: [
                    {name:'e',uuid: 5,theChild: []
                    }
                ]
            }
        ]
    }
]

Now, the options are coming through because I can access them from $onInit in my component, the settings seem to be set because I've enabled and disabled search in the dropdown; but for some reason it doesn't display any data. None of the options.

Moreover I'm getting the following error in the console:

 TypeError: Cannot read property 'childrenProperty' of undefined
    at e.value (component.js:formatted:261)
    at e.value (component.js:formatted:145)
    at new e (component.js:formatted:118)
    at Object.invoke (angular.js:5003)
    at $controllerInit (angular.js:10866)
    at nodeLinkFn (angular.js:9746)
    at angular.js:10154
    at processQueue (angular.js:16832)
    at angular.js:16876
    at Scope.$digest (angular.js:17971)

I have also tried to use it without the settings parameter and it throws the same error.

Any idea what the problem could be? To me it looks like either the this or the this.settings is undefined in that context..

@DmitryKurkin
Copy link

I am experiencing the same problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants