mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-22 02:10:12 +01:00
feat(rc5): update to angular rc.5
- NgaModule - module wrapper for all ng2-admin custom features - Ng Module per page - async components load - menu moved (again) to a separate file (as now each module has its own route file) - no need to import Ba* directives into the pages which have NgaModule in the import statement
This commit is contained in:
parent
983f6f1675
commit
5b7c132eac
86 changed files with 854 additions and 384 deletions
79
src/app/app.module.ts
Normal file
79
src/app/app.module.ts
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
import { NgModule, ApplicationRef } from '@angular/core';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
import { HttpModule } from '@angular/http';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { removeNgStyles, createNewHosts } from '@angularclass/hmr';
|
||||
|
||||
/*
|
||||
* Platform and Environment providers/directives/pipes
|
||||
*/
|
||||
import { ENV_PROVIDERS } from './environment';
|
||||
import { routing } from './app.routing';
|
||||
|
||||
// App is our top level component
|
||||
import { App } from './app.component';
|
||||
import { AppState } from './app.service';
|
||||
import { GlobalState } from './global.state';
|
||||
import { NgaModule } from './theme/nga.module';
|
||||
import { PagesModule } from './pages/pages.module';
|
||||
|
||||
// Application wide providers
|
||||
const APP_PROVIDERS = [
|
||||
AppState,
|
||||
GlobalState
|
||||
];
|
||||
|
||||
/**
|
||||
* `AppModule` is the main entry point into Angular2's bootstraping process
|
||||
*/
|
||||
@NgModule({
|
||||
bootstrap: [App],
|
||||
declarations: [
|
||||
App
|
||||
],
|
||||
imports: [ // import Angular's modules
|
||||
BrowserModule,
|
||||
HttpModule,
|
||||
RouterModule,
|
||||
FormsModule,
|
||||
ReactiveFormsModule,
|
||||
NgaModule,
|
||||
PagesModule,
|
||||
routing
|
||||
],
|
||||
providers: [ // expose our Services and Providers into Angular's dependency injection
|
||||
ENV_PROVIDERS,
|
||||
APP_PROVIDERS
|
||||
]
|
||||
})
|
||||
|
||||
export class AppModule {
|
||||
|
||||
constructor(public appRef: ApplicationRef, public appState: AppState) {
|
||||
|
||||
}
|
||||
|
||||
hmrOnInit(store) {
|
||||
if (!store && !store.state) return;
|
||||
console.log('HMR store', store);
|
||||
this.appState.state = store.state;
|
||||
delete store.state;
|
||||
}
|
||||
|
||||
hmrOnDestroy(store) {
|
||||
let cmpLocation = this.appRef.components.map(cmp => cmp.location.nativeElement);
|
||||
// recreate elements
|
||||
let state = this.appState.state;
|
||||
store.state = state;
|
||||
store.disposeOldHosts = createNewHosts(cmpLocation);
|
||||
// remove styles
|
||||
removeNgStyles();
|
||||
}
|
||||
|
||||
hmrAfterDestroy(store) {
|
||||
// display new elements
|
||||
store.disposeOldHosts();
|
||||
delete store.disposeOldHosts;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue