Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including ngx-remote-config with all npm packages installed. Try it out:

require("rxjs/package.json"); // rxjs is a peer dependency. require("@angular/common/package.json"); // @angular/common is a peer dependency. require("@angular/compiler/package.json"); // @angular/compiler is a peer dependency. require("@angular/core/package.json"); // @angular/core is a peer dependency. var ngxRemoteConfig = require("ngx-remote-config")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

ngx-remote-config v1.2.0

Remote configurations for Angular9+ applications, with built-in interceptor for mock REST data and non-permanent api

Build Status npm version

Remote configurations for Angular9+ applications, with built-in interceptor for mock REST data and non-permanent api

Installation

npm i --save ngx-remote-config

Links

Demo - Demo application with ngx-remote-config.

Stackblitz - Simply sample of usage on https://stackblitz.com

Demo settings - Settings for demo application stored on https://testapi.io

Demo Ionic - Example usage in ionic application with native HTTP module

path-to-regexp - Library usage for match url on interceptor

Usage

app.module.ts

import { HttpClientModule } from '@angular/common/http';
import { NgxRemoteConfigModule } from 'ngx-remote-config';

@NgModule({
  imports: [
    ...
    HttpClientModule,
    NgxRemoteConfigModule.forRoot({
      url: 'https://testapi.io/api/EndyKaufman/ngx-remote-config.json'
    }),
    ...
  ],
  ...
})
export class AppModule {}

app.component.html

...
<p>Load with directive</p>
<ng-container *remoteConfig="let config">
  {{config|json}}
</ng-container>
<p>Load with service</p>
<ng-container *ngIf="serviceConfig$ | async as serviceConfig">
  {{serviceConfig|json}}
</ng-container>
...

app.component.ts

import { NgxRemoteConfigService } from 'ngx-remote-config';
import { Observable } from 'rxjs';
...
serviceConfig$: Observable<any>;
constructor(
  private _ngxRemoteConfigService: NgxRemoteConfigService
) {
  this.serviceConfig$ = this._ngxRemoteConfigService.config$.asObservable();
}
...

settings.json (https://testapi.io/api/EndyKaufman/ngx-remote-config.json)

{
  "options":{
    "name":"Remote name",
    "description":"Remote description"
  },
  "/api/resource/2": {
    "get": {
      "status": 404,
      "body": {
        "message": "Fake not found message"
      }
    }
  },
  "/api/resource": {
    "get": [
      {
        "name": "get:item1"
      },
      {
        "name": "get:item2"
      },
      {
        "name": "get:item3"
      }
    ]
  },
  "/api/(.*)": "https://todo-nestjs.rucken.io/api/"
}

License

MIT

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free