How to use @angular/common - 10 common examples

To help you get started, we’ve selected a few @angular/common 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 UXAspects / UXAspects / e2e / pages / app / date-range-picker / date-range-picker.testpage.component.ts View on Github external
onRangeChange(): void {
        const start = this.start ? formatDate(this.start, 'd MMMM y  h:mm a', 'en-US') + ' ' + this._startTimezone.name : '';
        const end = this.end ? formatDate(this.end, 'd MMMM y  h:mm a', 'en-US') + ' ' + this._endTimezone.name : '';

        if (!this.start || !this.end) {
            return;
        }

        // reset the invalid state
        this.invalid = false;

        // check if the dates are valid
        if (this.getNormalizedDate(this.start, this._startTimezone).getTime() > this.getNormalizedDate(this.end, this._endTimezone).getTime()) {
            this.invalid = true;
        }

        // concatenate the two dates
        this.date = start && end ? `${start}${end}` : start || end;
github alvarotrigo / angular-fullpage / src / angular-fullpage / lib / fullpage.directive.ts View on Github external
ngAfterViewInit() {
    if (isPlatformBrowser(this.platformId)) {
      this.initFullpage();
    }
    if (isPlatformServer(this.platformId)) {
      // server side code
    }
  }
github locdb / locdb-frend / src / app / pipes / type-pipes / standard.pipe.ts View on Github external
transform(
    typedResource: TypedResourceView,
    forced_type: enums.resourceType = null,
    seperator: string = ', ',
    standalone: boolean = false,
  ): string {
    if (!typedResource) { return '(no resource)'; }
    /* Suffix for contributors, use colon (:) in standalone variants, else a comma (,) */
    const contrib_suffix = standalone ? ': ' : ', ';
    const identifierPepe = new IdentifierPipe();
    const authorsPepe = new AuthorsPipe();
    const editorsPepe = new EditorsPipe();
    const publisherPepe = new PublisherPipe();
    const datePepe = new DatePipe('en'); // locale
    let standardString = '';
    let trv = typedResource;
    if (forced_type != null) {
      // Change the view on the resource to the forced type
      trv = trv.astype(forced_type);
    }
    const title = typedResource.title
    const subtitle = typedResource.subtitle
    const publicationDate = typedResource.publicationDate
    // console.log('Date for title', title, publicationDate);
    const isoPublicationDate = datePepe.transform(publicationDate, 'yyyy');
    // console.log('YYYY date', title, isoPublicationDate);
    const contributors = typedResource.contributors;
    const authors = authorsPepe.transform(contributors, '; ', contrib_suffix);
    const editors = editorsPepe.transform(contributors, '; ', contrib_suffix);
    const publisher = publisherPepe.transform(contributors);
github metatron-app / metatron-discovery / discovery-frontend / src / app / monitoring / audit / job-log / component / job-detail / job-detail.component.ts View on Github external
public onClickOpenQueryModal(queryData: QueryHistory): void {
    const log: Log = new Log;
    const datePipe = new DatePipe('en-EN');
    log.title = 'QUERY';
    log.subTitle = [];
    // 생성시간 | 소요시간 | 성공여부
    log.subTitle.push(datePipe.transform(queryData.queryStartTime, 'yyyy-MM-dd HH:mm'));
    log.subTitle.push(queryData.queryTimeTakenFormatted);
    log.subTitle.push(queryData.queryResultStatus.toString());
    log.data = queryData.query;
    log.isShowCopy = true;
    // log 모달 오픈
    this.logEditorComponent.init(log);
  }
github usgs / earthquake-eventpages / src / app / tell-us / form-submit.service.spec.ts View on Github external
latitude: 35,
      longitude: -105
    };

    // Success Response
    feltResponseSucces = {
      ciim_mapLat: '35',
      ciim_mapLon: '-105',
      ciim_time: 'five minutes ago',
      eventid: '1234abcd',
      form_version: '1.2.3',
      your_cdi: 'I'
    };

    // Error Response
    feltResponseError = new HttpErrorResponse({
      status: 500,
      statusText: 'Server Error'
    });

    it('handles successes', inject(
      [FormSubmitService],
      (service: FormSubmitService) => {
        service.onSubmit(feltReport);
        const req = httpClient.expectOne(service.responseUrl);
        req.flush(feltResponseSucces);

        service.formResponse$.subscribe(response => {
          expect(response).toEqual(feltResponseSucces);
        });
      }
    ));
github OpenTOSCA / ui / src / app / core / service / deployment-completion.service.ts View on Github external
injectNewHosts(serviceTemplateURL: string, completionSelection: any): Promise<any> {
        const postURL = new Path(serviceTemplateURL)
            .append('injector')
            .append('replace')
            .toString();
        const httpOptions = {
            headers: new HttpHeaders({
                'Content-Type': 'application/json'
            }),
            observe: 'response'
        };
        this.logger.log('[deployment-completion.service][injectNewHosts][request-url]', JSON.stringify(postURL));

        // Todo See how to implement observe: 'response' application-management.service line 166
        // @ts-ignore
        return this.http.post<HttpResponse<any>>(postURL, completionSelection, httpOptions)
            .toPromise()
            .then(response => {
                const injectedserviceTemplateURL = response.headers.get('Location') as string;
                this.logger.log('[deployment-completion.service][injectNewHosts][response-location]', response.headers.get('Location'));
                return injectedserviceTemplateURL;
            });
    }
github MurhafSousli / ngx-gallery / lib / gallerize / src / gallerize.directive.ts View on Github external
// Add click event to the image
              this._renderer.setStyle(img, 'cursor', 'pointer');
              this._renderer.setProperty(img, 'onclick', () => this._lightbox.open(i, this.gallerize));
              return img;
            }),
            tap((img: HTMLImageElement) => images.push(new ImageItem(img.src, img.src))),
            finalize(() => galleryRef.load(images))
          );
        } else {
          return empty();
        }
      })
    ).subscribe();

    // Observe content changes
    if (isPlatformBrowser(this.platform)) {
      this.observer = new MutationObserver(() => this.gallerizer$.next());
      this.observer.observe(this._el.nativeElement, { childList: true, subtree: true });
    }
  }
github angular / flex-layout-builds / esm2015 / core.js View on Github external
lookupStyle(element, styleName, inlineOnly = false) {
        /** @type {?} */
        let value = '';
        if (element) {
            /** @type {?} */
            let immediateValue = value = this.lookupInlineStyle(element, styleName);
            if (!immediateValue) {
                if (isPlatformBrowser(this._platformId)) {
                    if (!inlineOnly) {
                        value = getComputedStyle(element).getPropertyValue(styleName);
                    }
                }
                else {
                    if (this._serverModuleLoaded) {
                        value = this._serverStylesheet.getStyleForElement(element, styleName);
                    }
                }
            }
        }
        // Note: 'inline' is the default of all elements, unless UA stylesheet overrides;
        //       in which case getComputedStyle() should determine a valid value.
        return value ? value.trim() : '';
    }
    /**
github angular / angular / packages / examples / common / pipes / ts / number_pipe.ts View on Github external
/**
 * @license
 * Copyright Google Inc. All Rights Reserved.
 *
 * Use of this source code is governed by an MIT-style license that can be
 * found in the LICENSE file at https://angular.io/license
 */

import {registerLocaleData} from '@angular/common';
import {Component} from '@angular/core';
// we need to import data for the french locale
import localeFr from './locale-fr';

// registering french data
registerLocaleData(localeFr);

// #docregion NumberPipe
@Component({
  selector: 'number-pipe',
  template: `<div>
    <!--output '2.718'-->
    <p>e (no formatting): {{e | number}}</p>
    
    <!--output '002.71828'-->
    <p>e (3.1-5): {{e | number:'3.1-5'}}</p>

    <!--output '0,002.71828'-->
    <p>e (4.5-5): {{e | number:'4.5-5'}}</p>
    
    <!--output '0 002,71828'-->
    <p>e (french): {{e | number:'4.5-5':'fr'}}</p>
github Alfresco / alfresco-content-app / src / app / app.module.ts View on Github external
import localeCs from '@angular/common/locales/cs';
import localePl from '@angular/common/locales/pl';
import localeFi from '@angular/common/locales/fi';
import localeDa from '@angular/common/locales/da';
import localeSv from '@angular/common/locales/sv';

registerLocaleData(localeFr);
registerLocaleData(localeDe);
registerLocaleData(localeIt);
registerLocaleData(localeEs);
registerLocaleData(localeJa);
registerLocaleData(localeNl);
registerLocaleData(localePt);
registerLocaleData(localeNb);
registerLocaleData(localeRu);
registerLocaleData(localeCh);
registerLocaleData(localeAr);
registerLocaleData(localeCs);
registerLocaleData(localePl);
registerLocaleData(localeFi);
registerLocaleData(localeDa);
registerLocaleData(localeSv);

@NgModule({
  imports: [
    BrowserModule,
    environment.e2e ? NoopAnimationsModule : BrowserAnimationsModule,
    FormsModule,
    ReactiveFormsModule,
    RouterModule.forRoot(APP_ROUTES, {
      useHash: true,
      enableTracing: false // enable for debug only