How to use the @angular/core.Pipe function in @angular/core

To help you get started, we’ve selected a few @angular/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github allenhwkim / ngentest / src / for-component / example / example.component.spec.ts View on Github external
}

@Injectable()
class MockCommonUtilsService {}

@Directive({ selector: '[oneviewPermitted]' }) // TODO, template must be user-configurable
class OneviewPermittedDirective {
  @Input() oneviewPermitted;
}

@Pipe({name: 'translate'}) // TODO, template must be user-configurable
class TranslatePipe implements PipeTransform {
  transform(value) { return value; }
}

@Pipe({name: 'phoneNumber'}) // TODO, template must be user-configurable
class PhoneNumberPipe implements PipeTransform {
  transform(value) { return value; }
}

@Pipe({name: 'safeHtml'}) // TODO, template must be user-configurable
class SafeHtmlPipe implements PipeTransform {
  transform(value) { return value; }
}

describe('ExampleComponent', () => {
  let fixture;
  let component;

  beforeEach(() => {
    TestBed.configureTestingModule({
      imports: [ FormsModule, ReactiveFormsModule ],
github cronoh / nanovault / src / app / pipes / fiat.pipe.ts View on Github external
import { Pipe, PipeTransform } from '@angular/core';
import {CurrencyPipe} from "@angular/common";
import {BigNumber} from 'bignumber.js';

@Pipe({
  name: 'fiat'
})
export class FiatPipe extends CurrencyPipe implements PipeTransform {
  // transform(value: any, currencyCode?: string, display?: 'code' | 'symbol' | 'symbol-narrow' | boolean, digits?: string, locale?: string): string | null;

  transform(value: any, currencyCode?: string, display?: 'code' | 'symbol' | 'symbol-narrow' | boolean, digits?: string, locale?: string): any {
    if (currencyCode === '') {
      return ``;
    }
    if (currencyCode === 'BTC') {
      return `BTC ${new BigNumber(new Number(value).toFixed(4) || 0).toFixed(6)}`;
    }
    return super.transform(value, currencyCode, 'symbol-narrow', digits, locale);
  }

}
github aviabird / angularspree / src / app / shared / pipes / sanitize-html.pipe.ts View on Github external
import { Pipe, PipeTransform } from '@angular/core';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';

@Pipe({ name: 'sanitizeHtml' })

/* DomSanitizer, a service of Angular helps to prevent attackers from injecting
   malicious client-side scripts into web pages, which is often referred as
   Cross-site Scripting or XSS.
*/
export class SanitizeHtmlPipe implements PipeTransform {
  constructor(private _sanitizer: DomSanitizer) {}

  transform(value: string): SafeHtml {
    return this._sanitizer.bypassSecurityTrustHtml(value);
  }
}
github dockstore / dockstore-ui2 / src / app / shared / entry / private-file-download.pipe.ts View on Github external
import { Pipe, PipeTransform } from '@angular/core';
import { FileService } from '../file.service';
import { SafeUrl } from '@angular/platform-browser';

@Pipe({
  name: 'privateFileDownload'
})
export class PrivateFileDownloadPipe implements PipeTransform {
  constructor(protected fileService: FileService) {}

  transform(content: string): SafeUrl {
    return this.fileService.getFileData(content);
  }
}
github Squidex / squidex / src / Squidex / app / framework / angular / pipes / name.pipe.ts View on Github external
/*
 * Squidex Headless CMS
 *
 * @license
 * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
 */

import { Pipe, PipeTransform } from '@angular/core';

import { StringHelper } from '@app/framework/internal';

@Pipe({
    name: 'sqxDisplayName',
    pure: true
})
export class DisplayNamePipe implements PipeTransform {
    public transform(value: any, field1 = 'label', field2  = 'name'): any {
        if (!value) {
            return '';
        }

        return StringHelper.firstNonEmpty(this.valueOf(value, field1), this.valueOf(value, field2));
    }

    private valueOf(o: any, s: string): any {
        s = s.replace(/\[(\w+)\]/g, '.$1');
        s = s.replace(/^\./, '');
github infra-geo-ouverte / igo2-lib / src / lib / filter / shared / filterable-layer.pipe.ts View on Github external
import { Pipe, PipeTransform } from '@angular/core';

import { Layer, FilterableLayer } from '../../layer';

@Pipe({
  name: 'filterableLayer'
})
export class FilterableLayerPipe implements PipeTransform {

  transform(value: Layer[], arg: string): any {
    let layers;

    if (arg === 'time') {
      layers = value.filter(layer => {
        return layer.isFilterable() && layer.options.timeFilter !== undefined;
      }) as any[] as FilterableLayer[];
    }

    return layers;
  }
github nkoehler / mat-video / src / app / video / pipes / seconds-to-time.pipe.ts View on Github external
import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
    name: 'secondsToTime'
})
export class SecondsToTimePipe implements PipeTransform {
    times = {
        year: 31557600,
        month: 2629746,
        day: 86400,
        hour: 3600,
    };

    transform(seconds: number) {
        if (!seconds)
            return '0:00';
        else {
            let time_string: string = '';
            for (const key in this.times) {
github TEAMMATES / teammates / src / web / app / components / question-edit-form / visibility-setting.pipe.ts View on Github external
case VisibilityControl.SHOW_RECIPIENT_NAME:
        return "Can see recipient's name";
      case VisibilityControl.SHOW_GIVER_NAME:
        return "Can see giver's name";
      default:
        return 'Unknown';
    }
  }

}

/**
 * Pipe to handle the detailed display of {@link FeedbackVisibilityType} in the context of
 * visibility control.
 */
@Pipe({
  name: 'visibilityTypeDescription',
})
export class VisibilityTypeDescriptionPipe implements PipeTransform {

  /**
   * Transforms {@code type} to a detailed description.
   */
  transform(type: FeedbackVisibilityType): any {
    switch (type) {
      case FeedbackVisibilityType.RECIPIENT:
        return 'Control what feedback recipient(s) can view';
      case FeedbackVisibilityType.INSTRUCTORS:
        return 'Control what instructors can view';
      case FeedbackVisibilityType.GIVER_TEAM_MEMBERS:
        return 'Control what team members of feedback giver can view';
      case FeedbackVisibilityType.RECIPIENT_TEAM_MEMBERS:
github linuxdeepin / deepin-appstore / src / web / src / app / dstore / pipes / app-info.ts View on Github external
import { Pipe, PipeTransform } from '@angular/core';
import { Subject } from 'rxjs';
import { scan, debounceTime, share, flatMap, map } from 'rxjs/operators';

import { AppService } from 'app/services/app.service';

@Pipe({
  name: 'appInfo',
})
export class AppInfoPipe implements PipeTransform {
  private query$ = new Subject();
  private result$ = this.getResult();
  constructor(private appService: AppService) {}
  getResult() {
    return this.query$.pipe(
      scan((list: string[], name: string) => [...list, name], []),
      debounceTime(10),
      flatMap(list => {
        return this.appService.getApps(list);
      }),
      share(),
    );
  }
github KingMario / packages / projects / ngx-lodash-pipes / src / lib / array / zip.pipe.ts View on Github external
/*
 * Copyright (c) 2019. Mario Studio. All right reserved.
 */

import {
  Pipe,
  PipeTransform,
} from '@angular/core';

import {
  List,
  zip,
} from 'lodash';

@Pipe({
  name: 'zip',
})
export class ZipPipe implements PipeTransform {

  transform (...arrays: Array | null | undefined>): Array> {
    return zip(...arrays);
  }

}