Angular1 <-> Angular2 Bridge accessing $rootScope
All that's needed is:
@Injectable()
class ExampleAngular2Service {
constructor(@Inject('$rootScope') private _rootScope: IRootScopeService) {}
}
You don't have to upgrade anything, it's there by default. See http://www.spaprogrammer.com/2017/03/inject-rootscope-into-angular-2.html
Tested on Angular 6 Hybrid using the now recommended:
import { UpgradeModule } from '@angular/upgrade/static';
You can also do this with $scope
@Inject('$scope') private $scope: IScope
So I will answer my own question.
You have to upgrade the $rootScope
in the following manner:
upgradeAdapter.upgradeNg1Provider('$rootScope')
Then it can be injected in the Angular2 service like follows:
@Injectable()
class ExampleAngular2Service {
constructor(@Inject('$rootScope') private _rootScope: any) {}
}