feat: add forChild and forLazy static methods

pull/4377/head
Arman Ozak 5 years ago
parent 0d7f7f2c19
commit 293eaf8c97

@ -1,9 +1,10 @@
import { CoreModule } from '@abp/ng.core';
import { CoreModule, LazyModuleFactory } from '@abp/ng.core';
import { ThemeSharedModule } from '@abp/ng.theme.shared';
import { NgModule, Provider } from '@angular/core';
import { ModuleWithProviders, NgModule, NgModuleFactory } from '@angular/core';
import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap';
import { NgxValidateCoreModule } from '@ngx-validate/core';
import { AccountRoutingModule } from './account-routing.module';
import { AuthWrapperComponent } from './components/auth-wrapper/auth-wrapper.component';
import { ChangePasswordComponent } from './components/change-password/change-password.component';
import { LoginComponent } from './components/login/login.component';
import { ManageProfileComponent } from './components/manage-profile/manage-profile.component';
@ -11,8 +12,8 @@ import { PersonalSettingsComponent } from './components/personal-settings/person
import { RegisterComponent } from './components/register/register.component';
import { TenantBoxComponent } from './components/tenant-box/tenant-box.component';
import { Options } from './models/options';
import { ACCOUNT_OPTIONS, optionsFactory } from './tokens/options.token';
import { AuthWrapperComponent } from './components/auth-wrapper/auth-wrapper.component';
import { ACCOUNT_OPTIONS } from './tokens/options.token';
import { accountOptionsFactory } from './utils/factory-utils';
@NgModule({
declarations: [
@ -33,4 +34,22 @@ import { AuthWrapperComponent } from './components/auth-wrapper/auth-wrapper.com
],
exports: [],
})
export class AccountModule {}
export class AccountModule {
static forChild(options: Options): ModuleWithProviders<AccountModule> {
return {
ngModule: AccountModule,
providers: [
{ provide: ACCOUNT_OPTIONS, useValue: options },
{
provide: 'ACCOUNT_OPTIONS',
useFactory: accountOptionsFactory,
deps: [ACCOUNT_OPTIONS],
},
],
};
}
static forLazy(options: Options): NgModuleFactory<AccountModule> {
return new LazyModuleFactory(AccountModule.forChild(options));
}
}

Loading…
Cancel
Save