A provider and a service that simplifies meta tags access
Note: This is intended only for use with dynamic meta tags such as browser color and title.
Tags that are only processed when the page is rendered (such as charset, and http-equiv)
will not work since $$mdMeta adds the tags after the page has already been loaded.
app.config(function($$mdMetaProvider) {
var removeMeta = $$mdMetaProvider.setMeta('meta-name', 'content');
var metaValue = $$mdMetaProvider.getMeta('meta-name'); // -> 'content'
removeMeta();
});
app.controller('myController', function($$mdMeta) {
var removeMeta = $$mdMeta.setMeta('meta-name', 'content');
var metaValue = $$mdMeta.getMeta('meta-name'); // -> 'content'
removeMeta();
});
| Returns | Description |
|---|---|
$$mdMeta.$service |
$$mdMeta.setMeta(name, content);
Creates meta element with the 'name' and 'content' attributes, if the meta tag is already created than we replace the 'content' value
| Parameter | Type | Description |
|---|---|---|
* name
string
|
string |
meta tag 'name' attribute value |
* content
string
|
string |
meta tag 'content' attribute value |
| Returns | Description |
|---|---|
function |
remove function |
$$mdMeta.getMeta(name);
Gets the 'content' attribute value of the wanted meta element
| Parameter | Type | Description |
|---|---|---|
* name
string
|
string |
meta tag 'name' attribute value |
| Returns | Description |
|---|---|
string |
content attribute value |