D
D
Denis Denis2016-03-02 00:11:45
Angular
Denis Denis, 2016-03-02 00:11:45

How to get value from parent scope in Angular directive?

Hello.
I wrote a directive, in which I need to get the property of an object located in the parent scope.

angular
    .module('module')
    .directive('civilization', function factory() {
    return {
        template: '<div class="civilization"></div>',
        replace: true,
        restrict: 'A',
        //// создавать/не создавать замыкание области видимости
        scope: false,
        // здесь находится основная функциональность директивы
        link: function (scope) {
            console.log(scope.node);
        }
    }
});

And, what a misfortune, in the console "undefined", although if you display it simply console.log(scope);
In the properties of this object there is a node property
Thank you

Answer the question

In order to leave comments, you need to log in

1 answer(s)
_
_ _, 2016-03-02
@golovewkin

Give an example where this directive is used along with code, where a node falls into the scope.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question