0.0.8 • Published 4 years ago

@steveylin/ng2-configure v0.0.8

Weekly downloads
2
License
MIT
Repository
-
Last release
4 years ago

Table of contents

Usage

Install package

npm i @steveylin/ng2-configure --save

Add into module to preload configure file

For example

File: app.module.ts

...
import { ConfigureModule, ConfigureLoader } from '@steveylin/ng2-configure';

/**
 * Main App Module
 */
@NgModule({
  declarations: [AppComponent],
  imports: [
    BrowserModule,
    // Use 'forRoot' to preload configure file you want
    ConfigureModule.forRoot(
      {
        key: 'datasources',
        path: './../assets/configs/datasources.json'
      }
    ),
    HttpClientModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule {}

File: app.component.ts

...
import { ConfigureLoader } from '@steveylin-libs/configure';

/**
 * Main App Component
 */
@Component({
  selector: 'steveylin-libs-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.less']
})
export class AppComponent implements OnInit {

  /**
   * @param configureLoader Configure load files service
   */
  constructor(private configureLoader: ConfigureLoader) {}

  /**
   * Initilailize component
   *
   * @method public
   */
  public ngOnInit(): void {
    const config = this.configureLoader.get<AppConfig>('datasources');
    console.log(config.mqtt);
  }

}

Preview

Status

npm version type

Copyright and license

Code and documentation copyright 2020 Steve Y Lin.

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago