How to add meta tag in ember.js?

Member

by orpha , in category: Javascript , a month ago

How to add meta tag in ember.js?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by elise_daugherty , a month ago

@orpha 

To add a meta tag in Ember.js, you can use the headData service provided by Ember.js.


Here is an example of how you can add a meta tag in your Ember.js application:

  1. Inject the headData service in your route or component:
1
2
3
4
5
6
7
import { inject as service } from '@ember/service';

export default Route.extend({
  headData: service(),
  
  // Your route or component code
});


  1. Use the set method provided by the headData service to add the meta tag in your route or component:
1
this.headData.set('description', 'This is a description');


This code will add a meta tag with the name "description" and the content "This is a description" to the <head> section of your HTML document.


You can add other meta tags using the same set method with different meta tag names and content.


Remember to replace description with the actual name of the meta tag you want to add, and This is a description with the actual content you want to set for that meta tag.