How to use where clause in Knex
Create refunds with Stripe
Load HTML with Cheerio
How to send POST request with Axios
Find intersection of array in Lodash
Powered by Official white Bloop logo with a period

Terms / Privacy / Search / Support

  • import { HttpClient } from '@angular/common/http';
    import { Pipe, PipeTransform } from '@angular/core';
    
    @Pipe({
      name: 'fetch',
      pure: false
    })
    export class FetchJsonPipe implements PipeTransform {
      private cachedData: any = null;
      private cachedUrl = '';
    
      constructor(private http: HttpClient) { }
    
      transform(url: string): any {
        if (url !== this.cachedUrl) {
          this.cachedData = null;
          this.cachedUrl = url;
          this.http.get(url).subscribe(result => this.cachedData = result);
        }
    
        return this.cachedData;
      }
    }
    Docs
  • import { Pipe, PipeTransform } from '@angular/core';
    /*
     * Raise the value exponentially
     * Takes an exponent argument that defaults to 1.
     * Usage:
     *   value | exponentialStrength:exponent
     * Example:
     *   {{ 2 | exponentialStrength:10 }}
     *   formats to: 1024
    */
    @Pipe({name: 'exponentialStrength'})
    export class ExponentialStrengthPipe implements PipeTransform {
      transform(value: number, exponent = 1): number {
        return Math.pow(value, exponent);
      }
    }
    Docs
  • import { enableProdMode } from '@angular/core';
    import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
    import { singleSpaAngularElements } from 'single-spa-angular/elements';
    
    import { AppModule } from './app/app.module';
    import { environment } from './environments/environment';
    
    if (environment.production) {
      enableProdMode();
    }
    
    const lifecycles = singleSpaAngularElements({
      template: '<app-custom-element />',
      // We can actually not rely on the `zone.js` library, our custom element
      // will behave itself as a zone-less application.
      bootstrapFunction: () =>
        platformBrowserDynamic().bootstrapModule(AppModule, { ngZone: 'noop' }),
    });
    
    export const bootstrap = lifecycles.bootstrap;
    export const mount = lifecycles.mount;
    export const unmount = lifecycles.unmount;
    Docs
  • import { Injectable } from '@angular/core';
    import { HttpClient } from '@angular/common/http';
    
    @Injectable()
    export class ConfigService {
      constructor(private http: HttpClient) { }
    }
    Docs
  • import { NgModule } from '@angular/core';
    import { CommonModule } from '@angular/common';
    
    @NgModule({
      imports: [
        CommonModule
      ],
      declarations: []
    })
    export class AppRoutingModule { }
    Docs
  • Powered by Official black Bloop logo with a period
    download the IDE extension

    View other examples