Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
A tool for updating meta-tags in an Angular application.
npm install --save ngmeta
First you'll need to pass the NGMeta
service as a providers
in your NgModule
.
import { NGMeta } from 'ngmeta';
...
@NgModule({
providers: [
NGMeta
],
bootstrap: [
AppComponent
]
})
export class AppModule { }
To dynamically edit this data whenever a page is loaded. Import NGMeta
into your component, then inside of your constructor pass in the NGMeta
service as an argument...
import { NGMeta } from 'ngmeta';
...
export class HomePage {
constructor(private _ngmeta: NGMeta) {}
}
Then in the component we can call our NGMeta
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>
Full documentation for the NGMeta service is available here.
For typing you can take two of ther interfaces that NGMeta
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;
}
Function | Description |
---|---|
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 scrollEnabled() | Returns boolean value if scroll to top is enabled, to call let scrollEnabled: boolean = this._ngmeta.scrollEnabled; . |
set scrollEnabled(scroll: boolean) | Sets wether <body></body> should scroll to top on route change, to call this._ngmeta.scrollEnabled = 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 happen, check out the changelog to see the latest changes.
1.2.2 (2017-07-05)
FAQs
A tool for updating meta tags in an Angular application.
The npm package ngmeta receives a total of 36 weekly downloads. As such, ngmeta popularity was classified as not popular.
We found that ngmeta demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.