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.

Accessing current scope's controller instance alias from within directives? #5526

@gsklee

Description

@gsklee

Say I've got:

<div ng-controller="NavCtrl as nav">
    <button app-hmm>Turn Red</button>
    <p ng-class="{
        'red': nav.active
    }"></p>
</div>
directive('appHmm', function(
){
    return {
        link: function(scope, element, attrs) {
            foo();
            bar();

            /*
            // I'd like to set `nav.active = true` here without hard-coding `nav`
            */
        }
    };
})

Is there a way to do it currently? If not, perhaps add a way to retrieve the current scope's controller instance alias from within directives?

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