@angular/core#PLATFORM_ID TypeScript Examples

The following examples show how to use @angular/core#PLATFORM_ID. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: base-local.storage.ts    From svvs with MIT License 6 votes vote down vote up
constructor(
    private memoryStorage: IMemoryStorage,
    // eslint-disable-next-line @typescript-eslint/ban-types
    @Inject(PLATFORM_ID) private platformId: Object
  ) {
    if (isPlatformBrowser(platformId) && storageAvailable('localStorage')) {
      this.storage = window.localStorage
    } else {
      this.storage = this.memoryStorage
    }
  }
Example #2
Source File: account.component.ts    From spurtcommerce with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
constructor(
    public router: Router,
    public activatedRoute: ActivatedRoute,
    public productControl: ProductControlSandbox,
    public listSandbox: ListsSandbox,
    @Inject(PLATFORM_ID) private platformId: Object,
    public commonSandbox: CommonSandbox
  ) {
    this.router.events
      .pipe(filter(event => event instanceof NavigationEnd))
      .pipe(map(() => this.activatedRoute))
      .pipe(
        map(route => {
          while (route.firstChild) {
            route = route.firstChild;
          }
          return route;
        })
      )
      .pipe(filter(route => route.outlet === 'primary'))
      .pipe(mergeMap(route => route.data))
      .subscribe(event => {
        this.pageInfo = event.breadcrumb;
      });
  }
Example #3
Source File: app.component.ts    From nestjs-angular-starter with MIT License 6 votes vote down vote up
constructor(
    private router: Router,
    private loadingBarService: LoadingBarService,
    public appService: AppService,
    @Inject(PLATFORM_ID) private platformId: unknown,
    @Inject(APP_ID) private appId: string,
  ) {
    if (isPlatformBrowser(platformId))
      this.router.events.subscribe(this.navigationInterceptor.bind(this));
  }
Example #4
Source File: product-filter.component.ts    From spurtcommerce with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
constructor(
    private router: Router,
    public listSandbox: ListsSandbox,
    private configService: ConfigService,
    private fb: FormBuilder,
    public route: ActivatedRoute,

    @Inject(PLATFORM_ID) private platformId: Object
  ) {
    this.route.params.subscribe(data => {
      if (data.id) {
        this.category = data.id;
      }
    });
  }
Example #5
Source File: header.component.ts    From rubic-app with GNU General Public License v3.0 6 votes vote down vote up
constructor(
    @Inject(PLATFORM_ID) platformId: Object,
    private readonly headerStore: HeaderStore,
    private readonly authService: AuthService,
    private readonly iframeService: IframeService,
    private readonly cdr: ChangeDetectorRef,
    private readonly storeService: StoreService,
    private readonly router: Router,
    private readonly errorService: ErrorsService,
    private readonly queryParamsService: QueryParamsService,
    private readonly swapFormService: SwapFormService,
    private readonly swapsService: SwapsService,
    private readonly myTradesService: MyTradesService,
    private readonly tokensService: TokensService,
    @Inject(WINDOW) private readonly window: Window,
    @Inject(DOCUMENT) private readonly document: Document,
    @Self() private readonly destroy$: TuiDestroyService,
    private readonly gtmService: GoogleTagManagerService,
    private readonly zone: NgZone
  ) {
    this.loadUser();
    this.advertisementType = 'default';
    this.currentUser$ = this.authService.getCurrentUser();
    this.isMobileMenuOpened$ = this.headerStore.getMobileMenuOpeningStatus();
    this.isMobile$ = this.headerStore.getMobileDisplayStatus();
    this.headerStore.setMobileDisplayStatus(this.window.innerWidth <= this.headerStore.mobileWidth);
    if (isPlatformBrowser(platformId)) {
      this.zone.runOutsideAngular(() => {
        this.setNotificationPosition();
        this.window.onscroll = () => {
          this.setNotificationPosition();
        };
      });
    }
    this.swapType$ = this.swapsService.swapMode$;
  }
Example #6
Source File: controls-product-detail.component.ts    From spurtcommerce with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
constructor(
    public snackBar: MatSnackBar,
    @Inject(PLATFORM_ID) private platformId: Object,
    public controlSandbox: ProductControlSandbox,
    public listSandbox: ListsSandbox,
    private router: Router,
    public wishlistSandbox: WishlistSandbox,

  ) {}
Example #7
Source File: base-session.storage.ts    From svvs with MIT License 6 votes vote down vote up
constructor(
  private memoryStorage: BaseMemoryStorage,
  // eslint-disable-next-line @typescript-eslint/ban-types
  @Inject(PLATFORM_ID) private platformId: Object
) {
    if (storageAvailable('sessionStorage')) {
      this.storage = window.sessionStorage
    } else {
      this.storage = this.memoryStorage
    }
}
Example #8
Source File: menu.component.ts    From spurtcommerce with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
constructor(public listSandbox: ListsSandbox,
                public appSettings: AppSettings,
                @Inject(PLATFORM_ID) private platformId: Object,
                public router: Router) {
        this.settings = this.appSettings.settings;
        if (isPlatformBrowser(this.platformId)) {
        const setTheme = localStorage.getItem('optionsTheme');
        this.settings.theme = setTheme;
        }
    }
Example #9
Source File: auth.effects.ts    From svvs with MIT License 6 votes vote down vote up
constructor(
    private dataPersistence: DataPersistence<IAuthStoreFeatureKey>,
    private authStorage: IAuthStorage,
    private authApollo: IAuthApollo,
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    @Inject(PLATFORM_ID) protected platformId: any,
  ) {
    super(AUTH_FEATURE_KEY)
  }
Example #10
Source File: options.component.ts    From spurtcommerce with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**             CHANGE THE COLORS PLATTE
   * set the color from localStorage,if localStorage have value or else
   * set color by default as green.
   * **/
  constructor(
    public appSettings: AppSettings,
    @Inject(PLATFORM_ID) private platformId: Object,
    private commonService: CommonService
  ) {
    this.settings = this.appSettings.settings;
    if (isPlatformBrowser(this.platformId)) {
      if (localStorage.getItem('optionsTheme')) {
        const tempColor = localStorage.getItem('optionsTheme');
        this.settings.theme = tempColor;
      } else {
        this.settings.theme = 'green';
      }
    }
  }
Example #11
Source File: company-stocks-chart.component.ts    From ng-conf-2020-workshop with MIT License 6 votes vote down vote up
constructor(private companiesService: CustomersService, @Inject(PLATFORM_ID) platform: object) {
    this.isBrowser = isPlatformBrowser(platform);
    this.companiesService.getCompaniesStock().subscribe(x => this.data = this.filteredData = x);
    this.companiesService.customerSelection.subscribe(d => {
      this.filteredData = this.data.filter(c => d.find(entry => entry === c[0].companyId));
      if (!this.filteredData.length) {
        this.filteredData = this.data;
      }
    });
  }
Example #12
Source File: product-control.sandbox.ts    From spurtcommerce with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
constructor(
    private router: Router,
    protected appState$: Store<store.AppState>,
    public snackBar: MatSnackBar,
    @Inject(PLATFORM_ID) private platformId: Object
  ) {
    this.productTotal = 0;
    this.completeOrder();
    if (isPlatformBrowser(this.platformId)) {
      const cartParams: any = {};
      cartParams.products = sessionStorage.getItem('selectedProducts')
        ? JSON.parse(sessionStorage.getItem('selectedProducts'))
        : [];
      cartParams.productTotal = sessionStorage.getItem('selectedProductsCount')
        ? +JSON.parse(sessionStorage.getItem('selectedProductsCount'))
        : 0;
      cartParams.totalPrice = sessionStorage.getItem('productTotal')
        ? +JSON.parse(sessionStorage.getItem('productTotal'))
        : 0;
      this.HandleCart(cartParams);
    }
    if (isPlatformServer(this.platformId)) {
    }
  }
Example #13
Source File: slick.component.ts    From flingo with MIT License 5 votes vote down vote up
/**
     * Constructor
     */
    constructor(private el: ElementRef, @Inject(PLATFORM_ID) private platformId: string) {}
Example #14
Source File: gantt-dom.service.ts    From ngx-gantt with MIT License 5 votes vote down vote up
constructor(private ngZone: NgZone, @Inject(PLATFORM_ID) private platformId: string) {}
Example #15
Source File: ngx-tippy-singleton.component.ts    From ngx-tippy-wrapper with MIT License 5 votes vote down vote up
constructor(
    @Inject(PLATFORM_ID) private platform: Object,
    private ngxTippyService: NgxTippyService,
    @Inject(NGX_TIPPY_MESSAGES) private messagesDict: NgxTippyMessagesDict
  ) {}
Example #16
Source File: safety-link.directive.ts    From rubic-app with GNU General Public License v3.0 5 votes vote down vote up
constructor(@Inject(PLATFORM_ID) private platformId: string, private router: Router) {}
Example #17
Source File: local-storage.ts    From ng-conf-2020-workshop with MIT License 5 votes vote down vote up
constructor(@Inject(PLATFORM_ID) platformId: object) {
    if (isPlatformBrowser(platformId)) {
      this.storage = localStorage;
    } else {
      this.storage = new LocalStorageFallback();
    }
  }
Example #18
Source File: ngx-splide.component.ts    From ngx-splide with MIT License 5 votes vote down vote up
constructor(private cdr: ChangeDetectorRef, @Inject(PLATFORM_ID) private platformId: any) { }
Example #19
Source File: app.component.ts    From App with MIT License 5 votes vote down vote up
constructor(
		@Inject(PLATFORM_ID) platformId: any,
		iconRegistry: MatIconRegistry,
		sanitizer: DomSanitizer,
		appService: AppService,
		titleService: Title,
		localStorageSvc: LocalStorageService,
		private windowRef: WindowRef,
		private sw: SwUpdate,
		private dialog: MatDialog,
		private location: Location,
		private router: Router,
		private overlayRef: OverlayContainer,
		public viewportService: ViewportService
	) {
		// Check if platform is browser
		AppComponent.isBrowser.next(isPlatformBrowser(platformId));

		for (const iconRef of iconList) {
			iconRegistry.addSvgIcon(
				iconRef[0],
				sanitizer.bypassSecurityTrustResourceUrl(`assets/${iconRef[1]}`)
			);
		}

		// Set page title
		{
			router.events.pipe( // Handle "ActivationStart" router event
				filter(ev => ev instanceof ActivationStart),
				map(ev => ev as ActivationStart),

				// Find variables and omit them from the title.
				// Components can call AppService.pushTitleAttributes() to update them
				tap(ev => {
					const title: string = '7TV - ' + (ev.snapshot.data?.title ?? 'Untitled Page' as string);

					appService.pageTitleSnapshot = String(title);
					titleService.setTitle(`${title?.replace(AppService.PAGE_ATTR_REGEX, '')}`);
				})
			).subscribe();
		}

		this.setTheme();

		if (isPlatformBrowser(platformId)) {
			localStorageSvc.storage = localStorage;
		}
	}
Example #20
Source File: users.effects.ts    From svvs with MIT License 5 votes vote down vote up
constructor(
    private dataPersistence: DataPersistence<IUsersStoreFeatureKey>,
    private userApollo: IUsersApollo,
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    @Inject(PLATFORM_ID) private platformId: any,
  ) {
    super(USERS_FEATURE_KEY)
  }
Example #21
Source File: image-viewer.component.ts    From nghacks with MIT License 5 votes vote down vote up
constructor(
    @Inject(DOCUMENT) private _nativeDocument: any,
    @Inject(MAT_DIALOG_DATA) private _data: ImageViewerDialogData,
    @Inject(PLATFORM_ID) private _platformId: any,
    private _dialogRef: MatDialogRef<ImageViewerComponent>,
  ) {
    this._document = this._nativeDocument as Document;
  }
Example #22
Source File: cloudflare-stream.component.ts    From stream-angular with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
constructor(
    private renderer2: Renderer2,
    @Inject(DocumentWrapper) private doc: DocumentWrapper,
    @Inject(PLATFORM_ID) private platformId: any
  ) {}
Example #23
Source File: ngx-hide-on-scroll.directive.ts    From Elastos.Essentials.App with MIT License 5 votes vote down vote up
constructor(
    private s: NgxHideOnScrollService,
    private elementRef: ElementRef<HTMLElement>,
    @Inject(PLATFORM_ID) private platformId: string
  ) { }
Example #24
Source File: ngx-tippy-group.component.ts    From ngx-tippy-wrapper with MIT License 5 votes vote down vote up
constructor(
    @Inject(PLATFORM_ID) private platform: Object,
    @Inject(NGX_TIPPY_MESSAGES) private messagesDict: NgxTippyMessagesDict
  ) {}
Example #25
Source File: common.effect.ts    From spurtcommerce with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
constructor(
    private actions$: Actions,
    @Inject(PLATFORM_ID) private platformId: Object,
    private authApi: CommonService
  ) {}
Example #26
Source File: ngx-tippy.directive.ts    From ngx-tippy-wrapper with MIT License 5 votes vote down vote up
constructor(
    private tippyEl: ElementRef,
    private renderer: Renderer2,
    private ngxTippyService: NgxTippyService,
    private ngxViewService: NgxViewService,
    private viewContainerRef: ViewContainerRef,
    @Inject(PLATFORM_ID) private platform: Object
  ) {}
Example #27
Source File: window.service.ts    From ng-ant-admin with MIT License 5 votes vote down vote up
constructor(@Inject(PLATFORM_ID) private platformId: object) {
    this.isBrowser = isPlatformBrowser(this.platformId);
  }
Example #28
Source File: search.component.ts    From loopback4-microservice-catalog with MIT License 5 votes vote down vote up
constructor(
    @Inject(SEARCH_SERVICE_TOKEN)
    private readonly searchService: ISearchService<T>,
    // tslint:disable-next-line:ban-types
    @Inject(PLATFORM_ID) private readonly platformId: Object,
    private readonly cdr: ChangeDetectorRef,
  ) {}
Example #29
Source File: CommonInterceptor.ts    From spurtcommerce with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
constructor(
    private router: Router,
    @Inject(PLATFORM_ID) private platformId: Object,
    private toastr: ToastrManager,
    public status: HTTPStatus
  ) {}