Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ngmeta

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ngmeta

A tool for updating meta tags in an Angular application.

  • 6.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
decreased by-60%
Maintainers
1
Weekly downloads
 
Created
Source

ngmeta Build Status

A tool for updating meta tags in an Angular application.

Getting Started

npm install --save ngmeta

How To Use

First import the NGMetaModule into your app.

import { NGMetaModule } from 'ngmeta';
...
@NgModule({
  imports: [
    NGMetaModule.forRoot()
  ],
  bootstrap: [
    AppComponent
  ]
})
export class AppModule { }

To dynamically edit this data whenever a page is loaded. Import NgMetaService into your component, then inside of your constructor pass in the NgMetaService service as an argument...

import { NgMetaService } from 'ngmeta';
...
export class HomePage {
    constructor(private _ngmeta: NGMeta) {}
}

Then in the component we can call our NgMetaService service this._ngmeta.setHead(). This takes an object of the new values for the tags you want. Below we change the title and description data on a page.

this._ngmeta.setHead({
  title: 'Google',
  meta : [
    {attribute: 'name', type: 'description', content: 'Search the world\'s information, including webpages, images, videos and more. Google has many special features to help you find exactly what you\'re looking for.'}
  ]
});

Now our head data will display

<head>
<title>Google</title>
<meta name='description' content='Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for.'>
</head>

Documentation

Full documentation for the NGMeta service is available here.

Interfaces

For typing you can take two of ther interfaces that NgMetaService uses by importing them with

import { TagData, MetaData } from 'ngmeta';
interface MetaData {
    type: string;
    content: string;
    attribute?: string;
}
interface TagData {
    title?: string;
    name?: MetaData[];
    property?: MetaData[];
    meta?: MetaData[];
    canonical?: string;
}

Functions

FunctionDescription
set canonical(canonicalURL: string)Sets canonical tag for page, to call this._ngmeta.canonical = 'https://www.google.com';.
public createMeta(metaData: MetaData)Creates HTML for a <meta> tag of any attribute.
get scroll()Returns boolean value if scroll to top is enabled, to call let scroll: boolean = this._ngmeta.scroll;.
set scroll(scroll: boolean)Sets wether <body></body> should scroll to top on route change, to call this._ngmeta.scroll = true;.
public setHead(tagData: TagData)Set function setting all <head></head> metadata.
get title()Returns string value of current page's title, to call let title: string = this._ngmeta.title;.
set title(title: string)Sets <title></title> tag for page, to call this._ngmeta.title = 'Google';.

Changes

Changes happen, check out the changelog to see the latest changes.

Keywords

FAQs

Package last updated on 10 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc