Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Extending a angular directives scope with a decorator not working in 1.3.8 #10583

Closed
subtubes-io opened this issue Dec 26, 2014 · 1 comment
Closed

Comments

@subtubes-io
Copy link

I have this code in version 1.2.1 but in version 1.3.8 I noticede it was not working any more here is a link to it working in 1.2.1 but locally I tested it with 1.3.8 and it no longer works. Also here is a link to the fiddle http://jsfiddle.net/377vhfm4/6/. Just wanted to know the new approach to this if there is one. Thanks.

    app.config(function ($provide) {


        $provide.decorator("exampleDirective", function ($delegate) {

            var directive = $delegate[0];
            var link = directive.link;

            //we add a new property to the scope
            angular.extend(directive.scope, {
                things: "="
            });

            directive.compile = function () {

                return function (scope, lElement) {

                    console.log(scope.things); //undefined

                    //we call the original link function
                    link.apply(this, arguments);

                    //it is undefined so we cannot add it to the page 
                    lElement.append('<span>' + scope.things + '</span>');

                }
            };

            return $delegate;
        })
    })
@lgalfaso
Copy link
Contributor

this looks like a duplicate of #10149

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

No branches or pull requests

2 participants