-
Notifications
You must be signed in to change notification settings - Fork 63
/
main.ts
58 lines (49 loc) · 1.97 KB
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/** * This file is the main entry point for the entire app.
*
* If the application is being bundled, this is where the bundling process
* starts. If the application is being loaded by an es6 module loader, this
* is the entry point.
*
* Point Webpack or SystemJS to this file.
*
* This module imports all the different parts of the application and registers them with angular.
* - Submodules
* - States
* - Components
* - Directives
* - Services
* - Filters
* - Run and Config blocks
* - Transition Hooks
* - 3rd party Libraries and angular1 module
*
* Then this module creates the ng-upgrade adapter
* and bootstraps the hybrid application
*/
// Google analytics
import './util/ga';
import 'zone.js';
import { NgZone } from '@angular/core';
////////////// HYBRID BOOTSTRAP ///////////////
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { UIRouter, UrlService } from '@uirouter/core';
import { visualizer } from '@uirouter/visualizer';
import { SampleAppModuleAngular } from './angularModule';
import { sampleAppModuleAngularJS } from "./angularJSModule";
// Using AngularJS config block, call `deferIntercept()`.
// This tells UI-Router to delay the initial URL sync (until all bootstrapping is complete)
sampleAppModuleAngularJS.config([ '$urlServiceProvider', ($urlService: UrlService) => $urlService.deferIntercept() ]);
// Manually bootstrap the Angular app
platformBrowserDynamic().bootstrapModule(SampleAppModuleAngular).then(platformRef => {
// Intialize the Angular Module
// get() the UIRouter instance from DI to initialize the router
const urlService: UrlService = platformRef.injector.get(UIRouter).urlService;
// Instruct UIRouter to listen to URL changes
function startUIRouter() {
urlService.listen();
urlService.sync();
}
platformRef.injector.get<NgZone>(NgZone).run(startUIRouter);
});
// Show ui-router-visualizer
sampleAppModuleAngularJS.run(['$uiRouter', ($uiRouter) => visualizer($uiRouter) ]);