@angular/core#inject TypeScript Examples
The following examples show how to use
@angular/core#inject.
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: success-trx-notification.component.ts From rubic-app with GNU General Public License v3.0 | 6 votes |
constructor(
@Inject(POLYMORPHEUS_CONTEXT)
private readonly context: TuiDialogContext<
void,
{ type: SuccessTxModalType; ccrProviderType: CrossChainProvider }
>
) {
this.type = context.data.type;
this.ccrProviderType = context.data.ccrProviderType;
}
Example #2
Source File: hero-select-dialog.component.ts From colo-calc with Do What The F*ck You Want To Public License | 6 votes |
constructor(
public dialogRef: MatDialogRef<HeroSelectDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: HeroSelectDialogData,
private characterService: CharacterService,
private localStorageService: LocalStorageService,
private dialog: MatDialog
) {
console.log(data);
if (this.data.party) {
this.selectedChars = this.data.party.tiles.reduce((acc, tile) => {
if (tile.character) {
acc.push(tile.character);
}
return acc;
}, []);
}
// Filter those out by default
if (this.onlyUniques === null) {
this.onlyUniques = true;
}
// Enable by default
if (this.separateByElement === null) {
this.separateByElement = true;
}
this.toggleRares();
this.filterField.valueChanges.subscribe(() => {
this.updateFilters();
});
}
Example #3
Source File: user.component.ts From App with MIT License | 6 votes |
constructor(
@Inject(DOCUMENT) private document: Document,
private router: Router,
private route: ActivatedRoute,
private appService: AppService,
private loggerService: LoggerService,
private restService: RestService,
private metaService: Meta,
private dataService: DataService,
private cdr: ChangeDetectorRef,
public clientService: ClientService,
public themingService: ThemingService
) { }
Example #4
Source File: session-details.component.ts From VIR with MIT License | 6 votes |
constructor(
public dialogRef: MatDialogRef<SessionDetailsComponent>,
private readonly dataStore: DataStore,
@Inject(MAT_DIALOG_DATA) public data: SessionDetailsConfig,
) {
this.dayID = data.dayID
this.type = data.type === undefined ? SessionType.SCHEDULED : data.type
this.count = data.count === undefined ? 1 : data.count
this.isEditing = !!data.isEditing
this.autoCompleter = dataStore.createAutoCompleter()
if (this.isEditing) {
if (data.itemID === undefined) {
throw new Error('Item ID not given when isEditing is true')
}
this.originalItemID = data.itemID
this.originalItemKey =
this.autoCompleter.idToKey(this.originalItemID)
if (this.originalItemKey === undefined) {
throw new Error('Item key not found')
}
this._itemKey = this.originalItemKey
this.originalType = data.type
this.originalCount = data.count
}
}
Example #5
Source File: auth.effects.ts From svvs with MIT License | 6 votes |
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 #6
Source File: emote.component.ts From App with MIT License | 6 votes |
constructor(
@Inject(DOCUMENT) private document: Document,
private metaService: Meta,
private restService: RestService,
private route: ActivatedRoute,
private router: Router,
private cdr: ChangeDetectorRef,
private dialog: MatDialog,
private appService: AppService,
private emoteListService: EmoteListService,
private dataService: DataService,
public themingService: ThemingService,
public clientService: ClientService
) { }
Example #7
Source File: base-cookie.service.ts From svvs with MIT License | 6 votes |
constructor(
@Inject(DOCUMENT) private document: Document,
// eslint-disable-next-line @typescript-eslint/ban-types
@Inject(PLATFORM_ID) private platformId: Object,
@Inject(REQUEST) @Optional() private request: Request,
@Inject(RESPONSE) @Optional() private response: Response,
) {
this.isBrowser = isPlatformBrowser(platformId)
}
Example #8
Source File: data-studio.service.ts From visualization with MIT License | 6 votes |
constructor(
@Inject(WINDOW) private readonly window: Window,
@Inject(MERMAID) private readonly mermaid: Mermaid,
private readonly alert: AlertService) {
this.initializeMermaid();
const azEvent$ = fromEvent<Event>(this.window, 'message').pipe(
tap(event => {
if (event.data.status === Status.Error) {
this.alert.showError({
status: event.data.status,
errors: event.data.errors,
rawData: JSON.stringify(event.data.rawData)
});
}
})
);
this.status$ = concat(azEvent$.pipe(
map(e => e.data?.status),
));
this.database$ = azEvent$.pipe(
filter(event => event.data?.status === Status.Complete),
map(event => event.data?.chart),
switchMap(r => this.buildSvg(r))
);
this.databaseName$ = azEvent$.pipe(
filter(event => event.data?.status === Status.Complete),
map(event => event.data?.databaseName));
}
Example #9
Source File: network-toggle.component.ts From thorchain-explorer-singlechain with MIT License | 6 votes |
constructor(@Inject(DOCUMENT) private document: Document) {
switch (environment.network) {
case 'TESTNET':
this.network = THORChainNetwork.TESTNET;
break;
default:
this.network = THORChainNetwork.CHAOSNET;
break;
}
}
Example #10
Source File: vulnerability-status-deployment-type-api.service.ts From barista with Apache License 2.0 | 6 votes |
constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) {
if (configuration) {
this.configuration = configuration;
}
if (typeof this.configuration.basePath !== 'string') {
if (typeof basePath !== 'string') {
basePath = this.basePath;
}
this.configuration.basePath = basePath;
}
this.encoder = this.configuration.encoder || new CustomHttpParameterCodec();
}
Example #11
Source File: outletService.ts From ngx-dynamic-hooks with MIT License | 6 votes |
constructor(
@Optional() @Inject(DYNAMICHOOKS_GLOBALSETTINGS) private globalSettings: DynamicHooksGlobalSettings,
private parserEntryResolver: ParserEntryResolver,
private optionsResolver: OptionsResolver,
private hooksReplacer: HooksReplacer,
private componentCreator: ComponentCreator,
private rendererFactory: RendererFactory2,
private injector: Injector
) {
this.renderer = rendererFactory.createRenderer(null, null);
}
Example #12
Source File: toggle.component.ts From canopy with Apache License 2.0 | 6 votes |
constructor(
@Self() @Optional() public control: NgControl,
@Optional()
@Inject(forwardRef(() => LgCheckboxGroupComponent))
private checkboxGroup: LgCheckboxGroupComponent,
private domService: LgDomService,
private errorState: LgErrorStateMatcher,
@Optional()
@Host()
@SkipSelf()
private controlContainer: FormGroupDirective,
private hostElement: ElementRef,
) {
this.selectorVariant = this.hostElement.nativeElement.tagName
.split('-')[1]
.toLowerCase();
if (this.checkboxGroup) {
return;
}
if (this.control != null) {
this.control.valueAccessor = this;
}
}
Example #13
Source File: company-stocks-chart.component.ts From ng-conf-2020-workshop with MIT License | 6 votes |
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 #14
Source File: success-tx-modal.component.ts From rubic-app with GNU General Public License v3.0 | 6 votes |
constructor(
private readonly destroy$: TuiDestroyService,
@Inject(POLYMORPHEUS_CONTEXT)
private readonly context: TuiDialogContext<
boolean,
{
idPrefix: string;
type: SuccessTxModalType;
txHash: string;
blockchain: BlockchainName;
ccrProviderType: CrossChainProvider;
}
>
) {
this.idPrefix = context.data.idPrefix;
this.type = context.data.type;
this.txHash = context.data.txHash;
this.blockchain = context.data.blockchain;
this.ccrProviderType = context.data.ccrProviderType;
timer(MODAL_CONFIG.modalLifetime)
.pipe(takeUntil(this.destroy$))
.subscribe(() => this.onConfirm());
}
Example #15
Source File: connect-hardware-wallet.component.ts From xBull-Wallet with GNU Affero General Public License v3.0 | 6 votes |
constructor(
private readonly hardwareWalletsService: HardwareWalletsService,
private readonly componentCreatorService: ComponentCreatorService,
private readonly globalsService: GlobalsService,
private readonly nzMessageService: NzMessageService,
@Inject(ENV)
private readonly env: typeof environment,
private readonly router: Router,
private readonly translateService: TranslateService,
) { }
Example #16
Source File: header.component.ts From rubic-app with GNU General Public License v3.0 | 6 votes |
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 #17
Source File: confirm-phrase-password.component.ts From xBull-Wallet with GNU Affero General Public License v3.0 | 6 votes |
constructor(
private readonly generateAccountQuery: GenerateAccountQuery,
private readonly cryptoService: CryptoService,
private readonly walletsService: WalletsService,
private readonly walletsQuery: WalletsQuery,
private readonly router: Router,
@Inject(ENV) private readonly env: typeof environment,
private mnemonicPhraseService: MnemonicPhraseService,
private readonly nzMessageService: NzMessageService,
private readonly translateService: TranslateService,
) { }
Example #18
Source File: wallet-connector.service.ts From rubic-app with GNU General Public License v3.0 | 6 votes |
constructor(
private readonly storage: StoreService,
private readonly errorService: ErrorsService,
private readonly httpService: HttpService,
private readonly iframeService: IframeService,
@Inject(WINDOW) private readonly window: RubicWindow,
@Inject(TUI_IS_IOS) private readonly isIos: boolean
) {
this.web3 = new Web3();
this.networkChangeSubject$ = new BehaviorSubject<BlockchainData>(null);
this.addressChangeSubject$ = new BehaviorSubject<string>(null);
}
Example #19
Source File: window.ts From common with MIT License | 6 votes |
WINDOW = new InjectionToken<Window>(
'An abstraction over global window object',
{
factory: () => {
const {defaultView} = inject(DOCUMENT);
if (!defaultView) {
throw new Error('Window is not available');
}
return defaultView;
},
},
)
Example #20
Source File: withdraw-liquidity.component.ts From xBull-Wallet with GNU Affero General Public License v3.0 | 6 votes |
constructor(
private readonly lpAssetsQuery: LpAssetsQuery,
private readonly walletsAccountsQuery: WalletsAccountsQuery,
private readonly walletsAccountsService: WalletsAccountsService,
private readonly liquidityPoolsService: LiquidityPoolsService,
private readonly horizonApiQuery: HorizonApisQuery,
private readonly stellarSdkService: StellarSdkService,
private readonly nzDrawerService: NzDrawerService,
private readonly nzMessageService: NzMessageService,
@Inject(ENV)
private readonly env: typeof environment,
private readonly translateService: TranslateService,
) { }
Example #21
Source File: app.component.ts From 1x.ag with MIT License | 6 votes |
constructor(
protected web3Service: Web3Service,
protected configurationService: ConfigurationService,
protected themeService: ThemeService,
protected swUpdate: SwUpdate,
protected appRef: ApplicationRef,
private deviceDetectorService: DeviceDetectorService,
@Inject(DOCUMENT) private document: Document
) {
}
Example #22
Source File: horizon-apis.store.ts From xBull-Wallet with GNU Affero General Public License v3.0 | 6 votes |
constructor(
@Inject(ENV)
private readonly env: typeof environment,
) {
super();
this.upsertMany(env.defaultApis.map(api => createHorizonApi(api)));
const storeValue = this.getValue();
if (!storeValue.active) {
this.setActive(env.production ? 'aa604e66a74ade3ef250f904ef28c92d' : '10a05029fe79fe9df15c33ee2e2d43bb');
}
}
Example #23
Source File: app.component.ts From rubic-app with GNU General Public License v3.0 | 6 votes |
constructor(
@Inject(DOCUMENT) private document: Document,
private readonly translateService: TranslateService,
private readonly cookieService: CookieService,
private readonly iframeService: IframeService,
private readonly gtmService: GoogleTagManagerService,
private readonly healthCheckService: HealthcheckService,
private readonly queryParamsService: QueryParamsService,
private readonly activatedRoute: ActivatedRoute,
private readonly errorService: ErrorsService
) {
this.printTimestamp();
this.initQueryParamsSubscription();
this.setupLanguage();
this.checkHealth();
}
Example #24
Source File: theme.service.ts From 1hop with MIT License | 6 votes |
constructor(
@Inject(DOCUMENT) private document: Document
) {
const mode = localStorage.getItem('mode') ? localStorage.getItem('mode') : 'dark';
this.isDarkMode = mode === 'dark';
this.document.body.classList.add(mode + '-mode');
}
Example #25
Source File: settings-list.component.ts From rubic-app with GNU General Public License v3.0 | 6 votes |
constructor(
private readonly headerStore: HeaderStore,
private readonly themeService: ThemeService,
private readonly cdr: ChangeDetectorRef,
private readonly translateService: TranslateService,
@Inject(POLYMORPHEUS_CONTEXT)
private readonly context$: BehaviorSubject<SettingsComponentData>
) {
this.settingsList = [
{
title: 'settings.header.switchTheme.title',
description: 'settings.header.switchTheme.desc',
component: new PolymorpheusComponent(ThemeSwitcherComponent),
action: this.switchTheme.bind(this)
},
{
title: 'settings.header.language.title',
description: 'settings.header.language.desc',
component: new PolymorpheusComponent(CurrentLanguageComponent),
action: this.switchToLanguageSettings.bind(this),
arrow: true
},
{
title: 'settings.header.gasPrice.title',
description: 'settings.header.gasPrice.desc',
component: new PolymorpheusComponent(GasIndicatorComponent),
arrow: false
},
{
title: 'settings.header.tutorials.title',
description: 'settings.header.tutorials.desc',
component: new PolymorpheusComponent(TutorialsComponent),
action: this.navigateExternalLink.bind(null, ['https://www.youtube.com/c/RubicExchange']),
arrow: true
}
];
}
Example #26
Source File: page-visibility.ts From common with MIT License | 6 votes |
PAGE_VISIBILITY = new InjectionToken<Observable<boolean>>(
'Shared Observable based on `document visibility changed`',
{
factory: () => {
const documentRef = inject(DOCUMENT);
return fromEvent(documentRef, 'visibilitychange').pipe(
startWith(0),
map(() => documentRef.visibilityState !== 'hidden'),
distinctUntilChanged(),
share(),
);
},
},
)
Example #27
Source File: theme.service.ts From rubic-app with GNU General Public License v3.0 | 6 votes |
constructor(private readonly store: StoreService, @Inject(DOCUMENT) private document: Document) {
const localTheme = (this.store.getItem('theme') as Theme) || 'dark';
this._theme$ = new BehaviorSubject<Theme>(localTheme);
if (localTheme !== 'dark') {
this.document.documentElement.classList.toggle('dark');
this.document.documentElement.classList.toggle('light');
} else {
document.getElementsByTagName('html')[0].classList.toggle('dark_colored');
}
}
Example #28
Source File: speech-recognition.ts From common with MIT License | 6 votes |
SPEECH_RECOGNITION = new InjectionToken<
// @ts-ignore
typeof window['speechRecognition'] | null
>('An abstraction over SpeechRecognition class', {
factory: () => {
const windowRef: any = inject(WINDOW);
return windowRef.speechRecognition || windowRef.webkitSpeechRecognition || null;
},
})
Example #29
Source File: insufficient-funds-error.component.ts From rubic-app with GNU General Public License v3.0 | 6 votes |
constructor(
@Inject(POLYMORPHEUS_CONTEXT)
private readonly context: TuiDialogContext<
void,
{ tokenSymbol: string; balance: string; requiredBalance: string }
>
) {
this.tokenSymbol = context.data.tokenSymbol;
this.balance = context.data.balance;
this.requiredBalance = context.data.requiredBalance;
}