npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ngx-configure

v9.0.0

Published

loads a general config object from json file before app initialization

Downloads

215

Readme

ngx-configure

Angular library to easily load a configuration file prior to application initialization and use it anywhere in your app.

In base of a Paul work Ng4-Cofigure ( https://github.com/mcdonaldp2/ng4-configure )

Usage

  1. Use NPM to install ngx-configure into your project.
npm install ngx-configure --save 
  1. Create a JSON config file for your project and store it somewhere accessible by the browser or in another server if you want.
{
  "name": "Catriel Müller",
  "favoriteColor": "Black",
  "google": "https://google.com",
  "ngx_configure_repo": "https://github.com/catrielmuller/ngx-configure/"
}

a) In the demo this is stored in src/assets/config.json

  1. Create a custom options class that extends NgxConfigureOptions:
import { NgxConfigureOptions } from 'ngx-configure';

export class AppOptions extends NgxConfigureOptions {
  ConfigurationURL = 'assets/appconfig.json';
  AppVersion = '0.0.0';
  BustCache = false;
}
  1. Add NgxConfigureModule, NgxConfigureOptions and your custom NgxConfigureOptions into your AppModule. Make sure to provide your custom ConfigureOptions. app.module.ts should look something like this:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { NgxConfigureModule, NgxConfigureOptions } from 'ngx-configure';
import { AppOptions } from './app.options';

import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    NgxConfigureModule.forRoot()
  ],
  providers: [
    { provide: NgxConfigureOptions, useClass: AppOptions }
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }
  1. Inject ConfigureService into any place in your project to access the config object in your code:

app.component.ts

import { Component } from '@angular/core';
import { NgxConfigureService } from 'ngx-configure';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  public config: any;

  constructor (configService: NgxConfigureService) {
    this.config = configService.config;
  }
}

app.component.html

<div style="text-align:center">
  <h1>
    Welcome to Ngx-Configure!
  </h1>  
</div>
<p>Loaded configuration from: <a href="/assets/appconfig.json" target="_blank">/assets/appconfig.json</a></p>
<pre>{{ config | json }}</pre>

ConfigureOptions Attributes

ConfigurationURL

Specifies the location of the configuration file. By default this location is set to 'assets/config.json'

AppVersion

Specifies the version of the application. To ensure that client browsers are getting the latest version of your config file after a release and not just a version that is cached in the browser, change this value when doing releases. The version will be appended to the url like so: http://localhost:1495/assets/config.json?v=<AppVersion> By default this is blank and will not append anything to the ConfigurationURL.

BustCache

If set to true, will generate a random value to end of the ConfigurationURL to ensure that the config file is never cached: http://localhost:1495/assets/config.json?t=<random value> By default this is set to false.