Skip to content

Commit

Permalink
fix(angularjs): Get AngularJS reference using 'getAngularJSGlobal()'
Browse files Browse the repository at this point in the history
Closes #240

BREAKING CHANGE: If 'angular' variable is not on the window, you must provide it using 'setAngularJSGlobal(angular);'.
https://github.com/ui-router/angular-hybrid/wiki/AngularJS-not-found-on-window
  • Loading branch information
christopherthielen committed Feb 12, 2019
1 parent 6c895ce commit d53d134
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/angular-hybrid.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import * as angular from 'angular';

import { Component, ElementRef, Inject, Injector, Input, ModuleWithProviders, NgModule } from '@angular/core';
import { downgradeComponent, UpgradeModule } from '@angular/upgrade/static';
import { downgradeComponent, UpgradeModule, getAngularJSGlobal, getAngularLib } from '@angular/upgrade/static';

import {
StateObject,
Expand Down Expand Up @@ -35,6 +33,15 @@ import { $InjectorLike, Ng1ViewConfig } from '@uirouter/angularjs';
import { UIRouterRx } from '@uirouter/rx';
import { NgHybridStatesModule } from './interfaces';

const getAngularJS = getAngularJSGlobal || getAngularLib;
const angular = getAngularJS();

if (!angular) {
throw new Error(
'AngularJS not found on window. https://github.com/ui-router/angular-hybrid/wiki/AngularJS-not-found-on-window'
);
}

/**
* Create a ng1 module for the ng1 half of the hybrid application to depend on.
*
Expand Down

0 comments on commit d53d134

Please sign in to comment.