-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
61 lines (50 loc) · 1.84 KB
/
index.js
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
59
60
61
import { Component as ngComponent, NgModule as ngModule, enableProdMode as enableProdMode } from '@angular/core';
import { RouterModule as routerModule, PreloadAllModules as preLoadAllModules } from '@angular/router';
import { platformBrowserDynamic as platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { BrowserModule as BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule as BrowserAnimationsModule } from '@angular/platform-browser/animations';
const useHash = true;
let ROUTES = [];
export const component = (prop, targetClass) => {
let services = null;
if( prop.service !== undefined ) {
services = prop.service;
delete prop.service;
}
let routeProp = null;
if( prop.route !== undefined ) {
routeProp = prop.route;
delete prop.route;
}
targetClass.annotations = [
new ngComponent(Object.assign({}, prop))
];
// check for any service injection
services ? targetClass.parameters = services : null
// check if has route config
// if YES then add it to routes
if(routeProp) {
// it as route prop set
ROUTES.push(
{
path: routeProp,
component: targetClass
}
);
}
return targetClass;
};
export const ngmodule = (prop, targetClass) => {
targetClass.annotations = [
new ngModule(Object.assign({}, prop))
];
return targetClass;
};
export const routerConfig = (ROUTES) => {
return RouterModule.forRoot(ROUTES, { useHash: useHash, preloadingStrategy: preLoadAllModules })
};
export const routeConfig = ROUTES;
export const browserPlatform = platformBrowserDynamic;
export const browserModule = BrowserModule;
export const appProdMode = enableProdMode;
export const browserAnimationModule = BrowserAnimationsModule;