Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
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

Description

@subtubes-io

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;
        })
    })

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions