Meta tags not display on page view source using angular 6.1

Discussão em 'Angular' iniciado por Mahi Kumawat, Julho 1, 2025.

  1. Mahi Kumawat

    Mahi Kumawat Guest

    I'm using Angular, I want to add meta tags dynamically.

    I am using form : https://www.npmjs.com/package/@ngx-meta/core

    npm install @ngx-meta/core --save


    I Tried the code below, it is showing in inspect element (console), but it is not showing on source code:

    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 { }


    It's working fine in inspect element but not showing any meta tags in page view source .

    Continue reading...

Compartilhe esta Página