Skip to content

Commit 30db03a

Browse files
refactor(ng2): Make UIView compatible with AoT compiler
1 parent 167770d commit 30db03a

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,11 @@
5858
"devDependencies": {
5959
"@angular/common": "^2.0.0",
6060
"@angular/compiler": "^2.0.0",
61+
"@angular/compiler-cli": "^0.6.2",
6162
"@angular/core": "^2.0.0",
6263
"@angular/platform-browser": "^2.0.0",
6364
"@angular/platform-browser-dynamic": "^2.0.0",
65+
"@angular/platform-server": "^2.0.0",
6466
"@types/angular": "^1.5.14",
6567
"@types/angular-animate": "^1.5.5",
6668
"@types/angular-mocks": "^1.5.5",

src/ng2/directives/uiView.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,17 @@ export class UIView {
129129
componentRef: ComponentRef<any>;
130130
deregister: Function;
131131
uiViewData: ActiveUIView = <any> {};
132+
parent: ParentUIViewInject;
132133

133134
static PARENT_INJECT = "UIView.PARENT_INJECT";
134135

135136
constructor(
136137
public router: UIRouter,
137-
@Inject(UIView.PARENT_INJECT) public parent: ParentUIViewInject,
138+
@Inject(UIView.PARENT_INJECT) parent,
138139
public viewContainerRef: ViewContainerRef
139-
) { }
140+
) {
141+
this.parent = parent;
142+
}
140143

141144
ngOnInit() {
142145
let parentFqn = this.parent.fqn;

src/ng2/uiRouterNgModule.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export class UIRouterModule {
8080
_UIROUTER_INSTANCE_PROVIDERS,
8181
_UIROUTER_SERVICE_PROVIDERS,
8282
{ provide: LocationStrategy, useClass: locationStrategy },
83-
...UIRouterModule.makeProviders(config, true),
83+
...makeProviders(config, true),
8484
]
8585
}
8686
}
@@ -113,21 +113,23 @@ export class UIRouterModule {
113113
static forChild(module: StatesModule = {}): ModuleWithProviders {
114114
return {
115115
ngModule: UIRouterModule,
116-
providers: UIRouterModule.makeProviders(module, false),
116+
providers: makeProviders(module, false),
117117
}
118118
}
119119

120-
static makeProviders(module: StatesModule, forRoot: boolean): Provider[] {
121-
let providers: Provider[] = [module.configClass]
122-
.filter(identity)
123-
.map(configClass => ({ provide: configClass, useClass: configClass }));
120+
}
124121

125-
if (forRoot) providers.push({ provide: UIROUTER_ROOT_MODULE, useValue: module, multi: true});
126-
providers.push({ provide: UIROUTER_MODULE_TOKEN, useValue: module, multi: true });
127-
providers.push({ provide: ANALYZE_FOR_ENTRY_COMPONENTS, useValue: module.states || [], multi: true });
128122

129-
return providers;
130-
}
123+
export function makeProviders(module: StatesModule, forRoot: boolean): Provider[] {
124+
let providers: Provider[] = [module.configClass]
125+
.filter(identity)
126+
.map(configClass => ({ provide: configClass, useClass: configClass }));
127+
128+
if (forRoot) providers.push({ provide: UIROUTER_ROOT_MODULE, useValue: module, multi: true});
129+
providers.push({ provide: UIROUTER_MODULE_TOKEN, useValue: module, multi: true });
130+
providers.push({ provide: ANALYZE_FOR_ENTRY_COMPONENTS, useValue: module.states || [], multi: true });
131+
132+
return providers;
131133
}
132134

133135
/**

0 commit comments

Comments
 (0)