@angular/core#ValueProvider TypeScript Examples

The following examples show how to use @angular/core#ValueProvider. 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: provide-location.ts    From universal with MIT License 6 votes vote down vote up
export function provideLocation(req: IncomingMessage): ValueProvider {
    const protocol = 'encrypted' in req.socket ? 'https' : 'http';
    const url: any = new URL(`${protocol}://${req.headers['host']}${req.url}`);

    url.assign = emptyFunction;
    url.reload = emptyFunction;
    url.replace = emptyFunction;
    url.ancestorOrigins = new (class extends Array<string> implements DOMStringList {
        contains(): boolean {
            return false;
        }

        item(): null {
            return null;
        }
    })();

    return {
        provide: SSR_LOCATION,
        useValue: url,
    };
}
Example #2
Source File: universal-animation-frame.ts    From universal with MIT License 5 votes vote down vote up
UNIVERSAL_ANIMATION_FRAME: ValueProvider = {
    provide: ANIMATION_FRAME,
    useValue: NEVER,
}
Example #3
Source File: universal-caches.ts    From universal with MIT License 5 votes vote down vote up
UNIVERSAL_CACHES: ValueProvider = {
    provide: CACHES,
    useValue: CACHES_MOCK,
}
Example #4
Source File: universal-crypto.ts    From universal with MIT License 5 votes vote down vote up
UNIVERSAL_CRYPTO: ValueProvider = {
    provide: CRYPTO,
    useValue: CRYPTO_MOCK,
}
Example #5
Source File: universal-history.ts    From universal with MIT License 5 votes vote down vote up
UNIVERSAL_HISTORY: ValueProvider = {
    provide: HISTORY,
    useValue: HISTORY_MOCK,
}
Example #6
Source File: universal-media-devices.ts    From universal with MIT License 5 votes vote down vote up
UNIVERSAL_MEDIA_DEVICES: ValueProvider = {
    provide: MEDIA_DEVICES,
    useValue: NAVIGATOR_MOCK.mediaDevices,
}
Example #7
Source File: universal-speech-synthesis.ts    From universal with MIT License 5 votes vote down vote up
UNIVERSAL_SPEECH_SYNTHESIS: ValueProvider = {
    provide: SPEECH_SYNTHESIS,
    useValue: SPEECH_SYNTHESIS_MOCK,
}
Example #8
Source File: provide-user-agent.ts    From universal with MIT License 5 votes vote down vote up
export function provideUserAgent(req: {headers: IncomingHttpHeaders}): ValueProvider {
    return {
        provide: SSR_USER_AGENT,
        useValue: req.headers['user-agent'],
    };
}