graycoreio/daffodil

View on GitHub
libs/seo/router/src/providers/title-provider.ts

Summary

Maintainability
A
0 mins
Test Coverage
import {
  APP_INITIALIZER,
  Provider,
} from '@angular/core';

import { initializeRouterService } from './initializer';
import { DaffSeoNativeTitleEffects } from '../effects/title.effects';

/**
 * Configures an Angular application to track routing configuration and subsequently set title information in the document.
 *
 * This provider is intended to only be imported exactly once in the root of the application.
 *
 * @deprecated since Angular 14. See https://angular.io/api/router/TitleStrategy Deprecated in version 0.78.0. Will be removed in version 0.81.0.
 *
 * ## Usage
 *
 * ```ts
 * @NgModule({
 *   providers: [
 *    daffSeoRouterTitleProvider()
 *   ],
 * })
 * export class AppModule { }
 * ```
 */
export const daffSeoRouterTitleProvider = (): Provider[] => [
  DaffSeoNativeTitleEffects,
  {
    provide: APP_INITIALIZER,
    useFactory: initializeRouterService,
    deps: [DaffSeoNativeTitleEffects],
    multi: true,
  },
];