Options
All
  • Public
  • Public/Protected
  • All
Menu

Class NgMetaService

Service that allows setting and updating of meta tags, title tags, and canonical tags.

Hierarchy

  • NgMetaService

Index

Constructors

constructor

  • new NgMetaService(_document: any, _router: Router): NgMetaService
  • Initializes service. Creates faux DOM component to abstractly interact with DOM. Subscribes to route events.

    Parameters

    • _document: any
    • _router: Router

    Returns NgMetaService

Properties

Private _document

_document: any

Private _dom

_dom: DomAdapter = getDOM()

Private _router

_router: Router

Private _scroll

_scroll: boolean = true

Accessors

canonical

  • set canonical(canonicalURL: string): void
  • Sets canonical tag for page, to call this._ngmeta.canonical = 'https://www.google.com';.

    Parameters

    • canonicalURL: string

      Canonical URL for the page.

    Returns void

scroll

  • get scroll(): boolean
  • set scroll(scroll: boolean): void
  • Returns boolean value if scroll to top is enabled, to call let scroll: boolean = this._ngmeta.scroll;.

    Returns boolean

    If scroll to top is enabled.

  • Sets wether <body></body> should scroll to top on route change, to call this._ngmeta.scroll = true;.

    Parameters

    • scroll: boolean

      If <body></body> should scroll.

    Returns void

    If scroll to top is enabled.

title

  • get title(): string
  • set title(title: string): void
  • Returns string value of current page's title, to call let title: string = this._ngmeta.title;.

    Returns string

    Current page's title.

  • Sets <title></title> tag for page, to call this._ngmeta.title = 'Google';.

    Parameters

    • title: string

      Title value for the page.

    Returns void

    Current page's title.

Methods

Private _removeTag

  • _removeTag(tagSelector: string): void
  • Removes HTML from <head></head> for a tag.

    Parameters

    • tagSelector: string

      Selector detail for tag to remove.

    Returns void

Private _scrollToTop

  • _scrollToTop(evt: RouterEvent): void
  • Scrolls web page to top of <body></body>.

    Parameters

    • evt: RouterEvent

    Returns void

createMeta

  • Creates HTML for a <meta> tag of any attribute.

    Parameters

    • metaData: MetaData

      The attribute (like 'name' or 'property') type (like 'description' or 'og:title') and content of the tag.

    Returns void

setHead

  • Set function setting all <head></head> metadata.

    Parameters

    • tagData: TagData

      An object of the new values for the tags an user wants.

    Returns void

Generated using TypeDoc