Reputation: 97
Example :
<key id="1">
<value>login</value>
<description>This is used in login screen</description>
<length>10</length>
<height>20</height>
</key>
Upvotes: 1
Views: 89
Reputation: 2576
there is no implementation to the Angular internal i18n tool to manipulate the meta tags, but it's planned for Angular Universal according to ocombe
you can manipulate meta tags with the Meta service included in Angular 4 and write your own methods.
Add Meta
to your app.component.ts
:
import { Meta } from '@angular/platform-browser';
add Meta
to your contructor:
constructor(private meta: Meta) {
Adding meta tags:
this.meta.addTag({ name: 'test', content: 'test1' });
// or many at once:
this.meta.addTags([
{ name: 'test', content: 'test2' },
{ name: 'test', content: 'test 3' },
{ name: 'testX', content: 'test 4' },
{ name: 'testY', content: 'test 5' },
]);
Getting meta tags:
// only gets the first occurrence if the attribute is used multiple times
console.log('tag: ' + this.meta.getTag('name=test').content);
// gets the outer html
this.meta.getTags('name="test"').forEach(value => console.log('html:', value));
// gets the content
this.meta.getTags('name="test"').forEach(value => console.log('content: ' + value.content));
// gets the object
console.log('object: ', this.meta.getTags('name="test"'));
Updating meta tags:
// only updates the first occurrence!
this.meta.updateTag({name: 'test', content: 'abc'});
Deleting meta tags:
// only deletes the first occurrence
this.meta.removeTag('name="test"');
// does the same as above but takes an `HTMLTagElement`instead of an attribute selector
this.meta.removeTagElement(this.meta.getTag('name=test'));
Upvotes: 1