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

ng-dynamic-config

v0.1.0

Published

Angular utility designed to streamline the process of bootstrapping an Angular application with dynamic configuration data. It allows you to fetch configuration files from specified URLs, manage them using a service, and dynamically register additional pr

Downloads

197

Readme

Application Configuration Library

The ng-dynamic-config library is an Angular utility designed to streamline the process of bootstrapping an Angular application with dynamic configuration data. It allows you to fetch configuration files from specified URLs, manage them using a service, and dynamically register additional providers based on the loaded configuration.

Features

  • Dynamic Configuration Loading: Load configuration data from multiple sources before bootstrapping your application.
  • Provider Management: Register additional providers dynamically based on the loaded configuration.
  • Type Safety: Ensure type safety when retrieving configuration data with the AppConfigService.

Getting Started with ng-dynamic-config

Follow these steps to set up and use the ng-dynamic-config library in your Angular application.

Step 1: Import Required Modules

In your main.ts or bootstrap.ts, import the necessary modules:

import { appConfig } from "./app/app.config";
import { AppComponent } from "./app/app.component";
// Make sure of this path
import { bootstrapApplication } from "ng-dynamic-config";

Step 2: Define Configuration Keys

export const simpleConfigKey = 'SIMPLE';

Step 3: Specify the Configuration File

// Path to your configuration file (Remote or Local) const configJson = 'testConfig.json';

Configuration JSON Example

Ensure your JSON file, testConfig.json, is structured as follows:

{
  "name": "Elpidio Mazza"
}

Step 4: Bootstrap the Application

bootstrapApplication(
  {
    [simpleConfigKey]: configJson, // Map your config keys to the respective JSON file
  },
  {}, // Default configuration values
  AppComponent, // Your root component
  true, // Inject FacadeConfigService
  appConfig // Additional application configuration
);

Step 5: Access Configuration Data in a Component

In your component (e.g., AppComponent), you can access the configuration data using the FacadeConfigService:

import { Component } from "@angular/core";
import { FacadeConfigService } from "./facade-config.service"; // Adjust the import path

export class AppComponent {
  title: string;

  constructor(private facade: FacadeConfigService) {
    this.title = facade.getConfig<{ name: string }>(simpleConfigKey).name; // Access the name from your configuration
  }
}

Conclusion

You have now set up the ng-dynamic-config library in your Angular application and can access configuration data dynamically. For further customization and advanced usage, refer to the library documentation.

Notes:

  • Make sure to adjust the import paths based on your project's structure.
  • You can add more details or examples if necessary, depending on the complexity of your application and configuration needs.