Meta

A service that can be used to get and add meta tags.

class Meta { addTag(tag: MetaDefinition, forceCreation: boolean = false): HTMLMetaElement | null addTags(tags: MetaDefinition[], forceCreation: boolean = false): HTMLMetaElement[] getTag(attrSelector: string): HTMLMetaElement | null getTags(attrSelector: string): HTMLMetaElement[] updateTag(tag: MetaDefinition, selector?: string): HTMLMetaElement | null removeTag(attrSelector: string): void removeTagElement(meta: HTMLMetaElement): void }

方法

addTag(tag: MetaDefinition, forceCreation: boolean = false): HTMLMetaElement | null

参数

tag

Type: MetaDefinition.

forceCreation

Type: boolean.

可选. 默认值是 false.

返回值

HTMLMetaElement | null

addTags(tags: MetaDefinition[], forceCreation: boolean = false): HTMLMetaElement[]

参数

tags

Type: MetaDefinition[].

forceCreation

Type: boolean.

可选. 默认值是 false.

返回值

HTMLMetaElement[]

getTag(attrSelector: string): HTMLMetaElement | null

参数

attrSelector

Type: string.

返回值

HTMLMetaElement | null

getTags(attrSelector: string): HTMLMetaElement[]

参数

attrSelector

Type: string.

返回值

HTMLMetaElement[]

updateTag(tag: MetaDefinition, selector?: string): HTMLMetaElement | null

参数

tag

Type: MetaDefinition.

selector

Type: string.

可选. 默认值是 undefined.

返回值

HTMLMetaElement | null

removeTag(attrSelector: string): void

参数

attrSelector

Type: string.

返回值

void

removeTagElement(meta: HTMLMetaElement): void

参数

meta

Type: HTMLMetaElement.

返回值

void

注解

@Injectable({ providedIn: 'root', useFactory: createMeta, deps: [] })