/
githubmirror
/
ionic-framework
Обзор
Документация
Войти
/
githubmirror
/
ionic-framework
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/angular/common/src/providers/config.ts
45 строк
1 KB
Liam DeBeasi
feat(angular): ship Ionic components as Angular standalone components (#28311)
10 окт 2023, 20:06
Не верифицирован
10 окт 2023, 20:06
57e2476
Код
Авторство
О чём код?
import { Injectable, InjectionToken } from '@angular/core'; import type { Config as CoreConfig, IonicConfig } from '@ionic/core/components'; import { IonicWindow } from '../types/interfaces'; @Injectable({ providedIn: 'root', }) export class Config { get(key: keyof IonicConfig, fallback?: any): any { const c = getConfig(); if (c) { return c.get(key, fallback); } return null; } getBoolean(key: keyof IonicConfig, fallback?: boolean): boolean { const c = getConfig(); if (c) { return c.getBoolean(key, fallback); } return false; } getNumber(key: keyof IonicConfig, fallback?: number): number { const c = getConfig(); if (c) { return c.getNumber(key, fallback); } return 0; } } export const ConfigToken = new InjectionToken<any>('USERCONFIG'); const getConfig = (): CoreConfig | null => { if (typeof (window as any) !== 'undefined') { const Ionic = (window as any as IonicWindow).Ionic; if (Ionic?.config) { return Ionic.config; } } return null; };