Я использую Angular , я хочу динамически добавлять метатеги.
Я использую форму: https://www.npmjs.com/package/@ngx-meta/core
npm install @ngx-meta/core --save
Я попробовал кодниже он отображается в элементе проверки (консоли), но не отображается в исходном коде:
import { NgModule } from '@angular/core';
import { MetaGuard } from '@ngx-meta/core';
import { MetaModule, MetaLoader, MetaStaticLoader, PageTitlePositioning } from '@ngx-meta/core';
import { Routes, RouterModule } from '@angular/router';
import { HomeComponent } from './home/home.component';
import { AboutComponent } from './about/about.component';
import { DashboardComponent } from './dashboard/dashboard.component';
import { ChildrouterComponent } from './about/childrouter/childrouter.component';
const routes: Routes = [
{
path: '',
canActivateChild: [MetaGuard],
children: [
{
path: 'home',
component: HomeComponent,
data: {
meta: {
title: 'home home',
keywords: 'home,home,home,home,home',
description: 'Home, home sweet home... and what?',
'og:image': 'https://upload.wikimedia.org/wikipedia/commons/f/f8/superraton.jpg',
'og:type': 'website',
'og:locale': 'en_US',
'og:locale:alternate': 'en_US,nl_NL,tr_TR'
}
}
},
{
path: 'about',
component: AboutComponent,
data: {
meta: {
title: 'about hello',
keywords: 'about,about,about,about,about,about,about',
description: 'Have you seen my rubber hello?',
'og:image': 'https://upload.wikimedia.org/wikipedia/commons/f/f8/superraton.jpg',
'og:type': 'website',
'og:locale': 'en_US',
'og:locale:alternate': 'en_US,nl_NL,tr_TR'
}
}
},
{
path: 'dashboard',
component: DashboardComponent,
data: {
meta: {
title: 'dashboard hello',
keywords: 'dashboard,dashboard,dashboard,dashboard,dashboard,dashboard,dashboard',
description: 'Have you seen my dashboard hello?',
'og:image': 'https://upload.wikimedia.org/wikipedia/commons/f/f8/superraton.jpg',
'og:type': 'website',
'og:locale': 'en_US',
'og:locale:alternate': 'en_US,nl_NL,tr_TR'
}
}
}
]
}
]
@NgModule({
imports: [RouterModule.forRoot(routes),
MetaModule.forRoot()
],
exports: [RouterModule]
})
export class AppRoutingModule { }
Он отлично работает в проверять элемент , но не отображает мета-теги на странице Просмотр источника .