angular-ui-router-title
angular-ui-router-title copied to clipboard
ngAnnotate just miss the $rootScope with default sample.
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!
I confirm, the fix above addressed errors in my project as well. Thanks @mutoo!
I think this might go a bit deeper than just making sure that $rootScope gets injected into the provider.
When I run grunt-ng-annotate this line causes it to error. When I comment out that line the error disappears. grunt-ng-annotate completes fine otherwise.