Skip to content

ngAnnotate just miss the $rootScope with default sample. #11

@mutoo

Description

@mutoo

I was using the ngAnnotate and uglifyjs in my project.

When I introduced the sample code into my file, it breaked the page after build.

$titleProvider.documentTitle(function($rootScope) {
    return $rootScope.$title ? $rootScope.$title + " - My Application" : "My Application";
});

It took a long time to find the reason before I awared that there is a dependency injection of $rootScope.

So I manually add the annotation for the sample code:

$titleProvider.documentTitle(["$rootScope", function($rootScope) {
    return $rootScope.$title ? $rootScope.$title + " - My Application" : "My Application";
}]);

or you can just use the "ngInject" directive:

$titleProvider.documentTitle(function($rootScope) {
    "ngInject";
    return $rootScope.$title ? $rootScope.$title + " - My Application" : "My Application";
});

it works again!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions