All Downloads are FREE. Search and download functionalities are using the official Maven repository.

typescript-angular.api.module.mustache Maven / Gradle / Ivy

import { NgModule, ModuleWithProviders, SkipSelf, Optional } from '@angular/core';
import { Configuration } from './configuration';
{{#useHttpClient}}import { HttpClient } from '@angular/common/http';{{/useHttpClient}}
{{^useHttpClient}}import { Http } from '@angular/http';{{/useHttpClient}}

{{#apiInfo}}
{{#apis}}
import { {{classname}} } from './{{importPath}}';
{{/apis}}
{{/apiInfo}}

@NgModule({
  imports:      [],
  declarations: [],
  exports:      [],
  providers: [{{^providedInRoot}}
    {{#apiInfo}}{{#apis}}{{classname}}{{#hasMore}},
    {{/hasMore}}{{/apis}}{{/apiInfo}} {{/providedInRoot}}]
})
export class {{apiModuleClassName}} {
    public static forRoot(configurationFactory: () => Configuration): ModuleWithProviders{{#enforceGenericModuleWithProviders}}<{{apiModuleClassName}}>{{/enforceGenericModuleWithProviders}} {
        return {
            ngModule: {{apiModuleClassName}},
            providers: [ { provide: Configuration, useFactory: configurationFactory } ]
        };
    }

    constructor( @Optional() @SkipSelf() parentModule: {{apiModuleClassName}},
                 @Optional() http: {{#useHttpClient}}HttpClient{{/useHttpClient}}{{^useHttpClient}}Http{{/useHttpClient}}) {
        if (parentModule) {
            throw new Error('{{apiModuleClassName}} is already loaded. Import in your base AppModule only.');
        }
        if (!http) {
            throw new Error('You need to import the {{#useHttpClient}}HttpClientModule{{/useHttpClient}}{{^useHttpClient}}HttpModule{{/useHttpClient}} in your AppModule! \n' +
            'See also https://github.com/angular/angular/issues/20575');
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy