Giter Site home page Giter Site logo

ng2-meta's Introduction

ng2-meta

Join the chat at https://gitter.im/ng2-meta/Lobby

Update HTML meta tags for title, description and others automatically based on the route in your Angular app.

ng2-meta v5.0.0+ requires Angular 6. On Angular 5 or lower, use ng2-meta v4.0.0 (npm install [email protected])

For the AngularJS (1.x) module, check out ngMeta

Getting started

Install

To install this library, run:

$ npm install ng2-meta --save

Modify routes

Add meta tags and MetaGuard to routes. By default, title and description values are duplicated for og:title and og:description, so there's no need to add them separately.


import { MetaGuard } from 'ng2-meta';

const routes: Routes = [
  {
    path: 'home',
    component: HomeComponent,
    canActivate: [MetaGuard],
    data: {
      meta: {
        title: 'Home page',
        description: 'Description of the home page'
      }
    }
  },
  {
    path: 'dashboard',
    component: DashboardComponent,
    canActivate: [MetaGuard],
    data: {
      meta: {
        title: 'Dashboard',
        description: 'Description of the dashboard page',
        'og:image': 'http://example.com/dashboard-image.png'
      }
    }
  }
];

Import MetaModule


...
import { MetaModule } from 'ng2-meta';

@NgModule({
  declarations: [
    AppComponent,
    ...
  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    RouterModule.forRoot(routes),
    MetaModule.forRoot()
  ],
  bootstrap: [AppComponent]
})

Update AppComponent


import { MetaService } from 'ng2-meta';

@Component({
  ...
})
export class AppComponent {
  constructor(private metaService: MetaService) {}
}

You're all set! ng2-meta will update the meta tags whenever the route changes.

Options

Set defaults

Set default values for tags. These values are used when routes without meta: {} information are encountered.

import { MetaConfig, MetaService } from 'ng2-meta';

const metaConfig: MetaConfig = {
  //Append a title suffix such as a site name to all titles
  //Defaults to false
  useTitleSuffix: true,
  defaults: {
    title: 'Default title for pages without meta in their route',
    titleSuffix: ' | Site Name',
    'og:image': 'http://example.com/default-image.png',
    'any other': 'arbitrary tag can be used'
  }
};

@NgModule({
  declarations: [
    AppComponent,
    ...
  ],
  imports: [
    ...,
    MetaModule.forRoot(metaConfig)
  ],
  bootstrap: [AppComponent]
})

Change meta tags programmatically

import { Component, OnInit } from '@angular/core';

class ProductComponent implements OnInit {
  ...
  constructor(private metaService: MetaService) {}

  ngOnInit() {
    this.product = //HTTP GET for product in catalogue
    this.metaService.setTitle('Product page for '+this.product.name);
    this.metaService.setTag('og:image',this.product.imageURL);
  }
}

Define fallback meta content in HTML

While Google executes Javascript and extracts meta tags set by ng2-meta, many bots (like Facebook and Twitter) do not execute Javascript. Consider defining fallback meta tags in your HTML for such bots. The fallback content is overridden by ng2-meta in Javascript-enabled environments.

<html>
  <head>
    <meta name="title" content="Website Name">
    <meta name="og:title" content="Website Name">
    <meta name="description" content="General description of your site">
    <meta name="og:description" content="General description of your site">
    <meta name="og:image" content="http://example.com/fallback-image.png">
  </head>
</html>

Contribute

If you wish to contribute to this repo, please check out the open issues.

If you notice a bug that has not already been reported or would like to make a feature request, please create a new issue. This helps to start a discussion with the community and avoid duplication of effort before you make any changes.

Licence

MIT © Vinay Gopinath

ng2-meta's People

Contributors

bergben avatar bioto avatar gitter-badger avatar vinaygopinath avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ng2-meta's Issues

Unable to setTag 'title'

With the current version of the plugin it is impossible to set the meta title tag differently from the setTitle <title> tag.

It gets overwritten bij de setTitle (at least for me).

It gives the following error:

Attempt to set title through 'setTag': 'title' and 'titleSuffix' are reserved tag names.
      Please use 'MetaService.setTitle' instead

I am only able to set the og:title.

Uncaught Error: Can't resolve all parameters for MetaService: ([object Object], ?, [object Object], [object Object], ?).

Uncaught Error: Can't resolve all parameters for MetaService: ([object Object], ?, [object Object], [object Object], ?).
at syntaxError (compiler.es5.js:1690)
at CompileMetadataResolver.webpackJsonp.../../../compiler/@angular/compiler.es5.js.CompileMetadataResolver._getDependenciesMetadata (compiler.es5.js:15769)
at CompileMetadataResolver.webpackJsonp.../../../compiler/@angular/compiler.es5.js.CompileMetadataResolver._getTypeMetadata (compiler.es5.js:15637)
at CompileMetadataResolver.webpackJsonp.../../../compiler/@angular/compiler.es5.js.CompileMetadataResolver._getInjectableMetadata (compiler.es5.js:15623)
at CompileMetadataResolver.webpackJsonp.../../../compiler/@angular/compiler.es5.js.CompileMetadataResolver.getProviderMetadata (compiler.es5.js:15914)
at compiler.es5.js:15843
at Array.forEach ()
at CompileMetadataResolver.webpackJsonp.../../../compiler/@angular/compiler.es5.js.CompileMetadataResolver._getProvidersMetadata (compiler.es5.js:15803)
at compiler.es5.js:15378
at Array.forEach ()

Upgrading to Angular 6 gives error this.router.events.filter is not a function

Hi,

Upgrading to Angular 6 gives the following error :
ERROR Error: Uncaught (in promise): TypeError: this.router.events.filter is not a function
TypeError: this.router.events.filter is not a function

I am using rxjs 6 and most probably, the change needed is that map and filter needs to be called using pipe function. Maybe the guide here : https://github.com/ReactiveX/rxjs/blob/master/docs_app/content/guide/v6/migration.md might help.

Can i set the metadata tags dynamically ?

I am getting the meta data tags for the pages from an API. Is there a way to set this dynamic meta data in the routes. Like the sample code below . Is is possible?

export const PublicPageRoutes: Array<any> = [
  { path: '', component: Home2Component, canActivate: [CanHomeActivateGuard], data: {
      meta: {
         title: AccountService.seoList['home']['page_title'],
        description:  AccountService.seoList['home']['description']
  }
}
,},

Does this work in RC5?

Hi

I have been using ng2-meta with RC4 and below. I have now updated my app to use RC5 and am no longer seeing the meta tags come through.

Does ng2-meta support RC5?

Installing the new v2.0.0 error

Hi,

My project is a basic Angular CLI project. I have installed Typescript 2.0.3 globally. This is what I get when trying to install the newly released version:

| => npm install

> [email protected] postinstall /Users/crash/git/traveliko/traveliko-spa-frontend/node_modules/ng2-meta
> tsc

node_modules/@types/core-js/index.d.ts(21,14): error TS2300: Duplicate identifier 'PropertyKey'.
node_modules/@types/core-js/index.d.ts(85,5): error TS2687: All declarations of 'name' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(145,5): error TS2403: Subsequent variable declarations must have the same type.  Variable '[Symbol.unscopables]' must be of type '{ copyWithin: boolean; entries: boolean; fill: boolean; find: boolean; findIndex: boolean; keys: ...', but here has type 'any'.
node_modules/@types/core-js/index.d.ts(262,5): error TS2687: All declarations of 'flags' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(276,5): error TS2687: All declarations of 'EPSILON' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(311,5): error TS2687: All declarations of 'MAX_SAFE_INTEGER' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(318,5): error TS2687: All declarations of 'MIN_SAFE_INTEGER' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(457,5): error TS2403: Subsequent variable declarations must have the same type.  Variable '[Symbol.toStringTag]' must be of type '"Symbol"', but here has type 'string'.
node_modules/@types/core-js/index.d.ts(457,5): error TS2687: All declarations of '[Symbol.toStringTag]' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(464,5): error TS2687: All declarations of 'prototype' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(492,5): error TS2687: All declarations of 'hasInstance' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(498,5): error TS2687: All declarations of 'isConcatSpreadable' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(504,5): error TS2687: All declarations of 'iterator' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(510,5): error TS2687: All declarations of 'match' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(516,5): error TS2687: All declarations of 'replace' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(522,5): error TS2687: All declarations of 'search' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(528,5): error TS2687: All declarations of 'species' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(534,5): error TS2687: All declarations of 'split' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(540,5): error TS2687: All declarations of 'toPrimitive' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(546,5): error TS2687: All declarations of 'toStringTag' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(552,5): error TS2687: All declarations of 'unscopables' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(609,5): error TS2403: Subsequent variable declarations must have the same type.  Variable '[Symbol.toStringTag]' must be of type '"Math"', but here has type 'string'.
node_modules/@types/core-js/index.d.ts(609,5): error TS2687: All declarations of '[Symbol.toStringTag]' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(613,5): error TS2403: Subsequent variable declarations must have the same type.  Variable '[Symbol.toStringTag]' must be of type '"JSON"', but here has type 'string'.
node_modules/@types/core-js/index.d.ts(613,5): error TS2687: All declarations of '[Symbol.toStringTag]' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(628,5): error TS2687: All declarations of 'size' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(634,5): error TS2687: All declarations of 'prototype' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(645,5): error TS2687: All declarations of 'size' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(651,5): error TS2687: All declarations of 'prototype' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(666,5): error TS2687: All declarations of 'prototype' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(680,5): error TS2687: All declarations of 'prototype' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(692,5): error TS2687: All declarations of 'value' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(804,5): error TS2687: All declarations of 'prototype' must have identical modifiers.
../typescript/lib/lib.es2015.core.d.ts(17,14): error TS2300: Duplicate identifier 'PropertyKey'.
npm ERR! Darwin 16.0.0
npm ERR! argv "/usr/local/Cellar/node/6.6.0/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v6.6.0
npm ERR! npm  v3.10.8
npm ERR! code ELIFECYCLE

npm ERR! [email protected] postinstall: `tsc`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the [email protected] postinstall script 'tsc'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the ng2-meta package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     tsc
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs ng2-meta
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls ng2-meta
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:

postInstall: typings install

Hey there!

The script "postinstall": "typings install" creates some trouble when deploying to Heroku.
Why do you need the typings install as a postInstall script? I have created a pull request here to change that... #9. This pull would fix this issue.

The problem is that on Heroku all npm packages are installed from a start so typings isn't installed at the moment when ng2-meta gets installed -> therefore an error is thrown and the application can't be deployed.

Tag specified as 'name' instead of 'property'

The following meta tags are specified using 'name' instead of 'property' and will be ignored unless specified using the 'property' key: fb:app_id

I use ng2-meta tag function, but in facebook debugger, I am getting this error.

I have checked the ng2-meta code for ng2-meta.umd.js file, here is the code:

function (tag, value) {
/** @type {?} */
var prop = 'name';
if (tag.startsWith("og:")) {
prop = 'property';
}
this.meta.updateTag((_a = {},
_a[prop] = tag,
_a.content = value,
_a));
var _a;
};

fb:app_id does not have og keyword, that is what is creating the problem.
Plugin needs to be updated by the author.

regarding metatags for fb:

it only works when i put:

<!-- Facebook integration -->
<meta name="og:url" content="" />
<meta name="og:type" content="" />
<meta name="og:title" content="" />
<meta name="og:description" content="" />
<meta name="og:image" content="" />

but if i do this it wont work. fb says it should be property not name

<!-- Facebook integration -->
<meta property="og:url" content="" />
<meta property="og:type" content="" />
<meta property="og:title" content="" />
<meta property="og:description" content="" />
<meta property="og:image" content="" />

Bug when setting the title programmatically

If you're setting the title programmatically and you are clicking on the same route twice, the title is empty. On the first click, ngOnInit is called and the title is set. On the second click, the method isn't called again, and the ng2-meta plugin uses the title from the route (which is not definded, because i want to set the title programmatically).
Perhaps there should be a configuration flag (per route) for disabling the route titles.

Error: No provider for Title!

Hi,

everything is working perfectly when I don't use server-side rendering but when I use it I get this exception

Exception: Call to Node module failed with error: Error: Uncaught (in promise): Error: No provider for Title!

any ideas?

ng2-meta issue in systemjs

I setup component as per your instruction, but could not get it work. I am using SystemJS, error below:

Unhandled Promise rejection:

(SystemJS) expected expression, got '<'
@http://localhost:3000/app.module.js:22:18
@http://localhost:3000/app.module.js:1:31
@http://localhost:3000/app.module.js:1:2
@http://localhost:3000/index.js:3:20
@http://localhost:3000/index.js:1:31
@http://localhost:3000/index.js:1:2
ZoneDelegate.prototype.invoke@http://localhost:3000/zone.js/dist/zone.js?rev=@@hash:232:17
Zone.prototype.run@http://localhost:3000/zone.js/dist/zone.js?rev=@@hash:114:24
scheduleResolveOrReject/<@http://localhost:3000/zone.js/dist/zone.js?rev=@@hash:502:52
ZoneDelegate.prototype.invokeTask@http://localhost:3000/zone.js/dist/zone.js?rev=@@hash:265:21
Zone.prototype.runTask@http://localhost:3000/zone.js/dist/zone.js?rev=@@hash:154:28
drainMicroTaskQueue@http://localhost:3000/zone.js/dist/zone.js?rev=@@hash:401:25
ZoneTask/this.invoke@http://localhost:3000/zone.js/dist/zone.js?rev=@@hash:339:25

Evaluating http://localhost:3000/ng2-meta.js
Evaluating http://localhost:3000/app.module.js
Evaluating http://localhost:3000/index.js
Error loading http://localhost:3000/index.js

; Zone: ; Task: Promise.then ; Value:
Error: (SystemJS) expected expression, got '<' @http://localhost:3000/app.module.js:22:18 @http://localhost:3000/app.module.js:1:31 @http://localhost:3000/app.module.js:1:2 @http://localhost:3000/index.js:3:20 @http://localhost:3000/index.js:1:31 @http://localhost:3000/index.js:1:2 ZoneDelegate.prototype.invoke@http://localhost:3000/zone.js/dist/zone.js?rev=@@hash:232:17 Zone.prototype.run@http://localhost:3000/zone.js/dist/zone.js?rev=@@hash:114:24 scheduleResolveOrReject/<@http://localhost:3000/zone.js/dist/zone.js?rev=@@hash:502:52 ZoneDelegate.prototype.invokeTask@http://localhost:3000/zone.js/dist/zone.js?rev=@@hash:265:21 Zone.prototype.runTask@http://localhost:3000/zone.js/dist/zone.js?rev=@@hash:154:28 drainMicroTaskQueue@http://localhost:3000/zone.js/dist/zone.js?rev=@@hash:401:25 ZoneTask/this.invoke@http://localhost:3000/zone.js/dist/zone.js?rev=@@hash:339:25 Evaluating http://localhost:3000/ng2-meta.js Evaluating http://localhost:3000/app.module.js Evaluating http://localhost:3000/index.js Error loading http://localhost:3000/index.js

My App.Module.ts file is:

import { NgModule } from '@angular/core';
import { HttpModule } from '@angular/http';
import { FormsModule,
FormBuilder } from '@angular/forms';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { LayoutModule } from './layout/layout.module';

import { HeaderComponent } from './layout/components/header';
import { PrivateHeaderComponent } from './layout/components/privateheader';
import { HomeBannerComponent } from './layout/components/homebanner';
import { FooterComponent } from './layout/components/footer';

import { routing,
appRoutingProviders } from './app.routing';
import { MetaModule } from 'ng2-meta';

import { SharedModule } from './shared/shared.module';
import { sharedrouting } from './shared/shared.routing';

import { AppService } from './app.service';

@NgModule({
imports: [
BrowserModule,
FormsModule,
HttpModule,
LayoutModule,
SharedModule,
sharedrouting,
routing,
MetaModule.forRoot()
],
declarations: [
AppComponent,
HeaderComponent,
PrivateHeaderComponent,
HomeBannerComponent,
FooterComponent
],
providers: [
appRoutingProviders,
AppService
],
bootstrap: [
AppComponent
],
})
export class AppModule { }

How do I change the canonical tag ?

Hi,

How do I make the canonical tag change. I've got the title, description and keywords changing ok.

Do I simply do this:

 {
    path: 'home',
    component: HomeComponent,
    data: {
      meta: {
        title: 'Home page',
        description: 'Description of the home page', 
        canonical: 'mywebsite.com/home' 
      }
    }
  }

I'm using angular version 4, with webpack, typescript and ng2-meta plugin. I just need to make the canonical tag change in runtime like the description changes. Is this possible?

This doesn't seem to work with my Angular2 app that has lazy loaded routes/views

This doesn't seem to work with my Angular2 app that has lazy loaded routes/views.

Google uses my default homepage title, and meta description / keywords for all pages.

This is my website: https://thepoolcover.co.uk/

This is the evidence of google indexing all the home meta: https://www.google.co.uk/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=site%3Athepoolcover.co.uk

It looks like it works but google doesnt see the changes. Could it be something to do with the bootrapping of the app?

ERROR in Error encountered resolving symbol values statically.

My application uses angular2.4. When run ng serve i have next error

ERROR in Error encountered resolving symbol values statically. Calling function 'MetaModule', function calls are not supported. Consider replacing the function or lambda wit
h a reference to an exported function, resolving symbol AppModule in /project/src/app/app.module.ts, resolving symbol AppModule in /project/src/app/app.module.ts

how resolve this trouble? Thank's

error with new Angular 4.0.0

Error: ERROR in Error encountered resolving symbol values statically. Calling function 'MetaModule', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol AppModule in D:/shopnx/src/app/app.module.ts, resolving symbol AppModule in D:/shopnx/src/app/app.module.ts

Env:

angular-cli 1.0.0
angular 4.0.0

When I do ng serve The above error comes. Although it still allows me to run the application, but it does not allow me to create a production build.

Meta tags & og are not detectable by facebook share

I am using Angular 2 + Meteor 1.4 & I have successfully integrated this package and I can see the titles on my web pages.

But when I check my website url on Facebook Sharing Debugger i.e:

https://developers.facebook.com/tools/debug/sharing

It doesn't shows the page title or the image etc on facekook and it gives these errors:

Missing Required Property
The 'og:type' property is required, but not present.

Inferred Property
The 'og:url' property should be explicitly provided, even if a value can be inferred from other tags.

Share App ID Missing
The 'fb:app_id' property should be explicitly provided, Specify the app ID so that stories shared to Facebook will be properly attributed to the app. Alternatively, app_id can be set in url when open the share dialog.

Inferred Property
The 'og:image' property should be explicitly provided, even if a value can be inferred from other tags.

Why is this so?

Cannot find module 'ng2-meta'

Not sure why but everything else installs and links up with a simple npm install. Any reason that these specific modules would not get picked up? My import statement is as follows.
import {MetaConfig, MetaModule} from 'ng2-meta';

My package.json is below.

{
  "name": "my web stack",
  "version": "1.0.0-beta.1",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "start": "ng serve",
    "lint": "tslint \"src/**/*.ts\"",
    "test": "ng test",
    "pree2e": "webdriver-manager update",
    "e2e": "protractor"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "~2.2.0",
    "@angular/compiler": "~2.2.0",
    "@angular/core": "~2.2.0",
    "@angular/forms": "~2.2.0",
    "@angular/http": "~2.2.0",
    "@angular/platform-browser": "~2.2.0",
    "@angular/platform-browser-dynamic": "~2.2.0",
    "@angular/router": "~3.2.0",
    "angular2-google-maps": "~0.15.0",
    "core-js": "~2.4.1",
    "ng2-bootstrap": "~1.1.14",
    "ng2-cli-sweetalert2": "0.0.2",
    "ng2-cloudinary": "^0.6.0",
    "ng2-datepicker": "^1.1.1",
    "ng2-meta": "github:vinaygopinath/ng2-meta",
    "ng2-translate": "^3.1.2",
    "ng2-validators": "~1.5.1",
    "rxjs": "5.0.0-beta.12",
    "ts-helpers": "~1.1.1",
    "zone.js": "~0.6.25"
  },
  "devDependencies": {
    "@types/jasmine": "^2.2.30",
    "@types/node": "^6.0.42",
    "angular-cli": "^1.0.0-beta.18",
    "codelyzer": "1.0.0-beta.1",
    "jasmine-core": "2.4.1",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "1.2.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-remap-istanbul": "^0.2.1",
    "protractor": "4.0.9",
    "ts-node": "1.2.1",
    "tslint": "3.13.0",
    "typescript": "2.0.3"
  }
}

no providers for meta.config

Hey there,

first of all nice work. Wanted to ask if RC4 is supported?
I am getting
browser_adapter.js:84ORIGINAL EXCEPTION: No provider for meta.config! :(

this is my app.ts

import "reflect-metadata";
import "zone.js/dist/zone";
import { Component } from "@angular/core";
import { bootstrap } from "@angular/platform-browser-dynamic";
import { appRouterProviders } from "./app.routes";
import { ROUTER_DIRECTIVES } from "@angular/router";
import { Title } from '@angular/platform-browser';
import template from "./app.html";
import { MetaService } from "ng2-meta";

@Component({
  selector: "app",
  template,
  directives: [ROUTER_DIRECTIVES],
  providers: [MetaService]
})

export class app {
  constructor(private metaService: MetaService) {}
}

bootstrap(app, [
  appRouterProviders,
  Title,
  MetaService
])
.catch(err => console.error(err));

routes:

const routes: RouterConfig = [
  { path: "blog", component: Blog,
        children:[
            { path: "", component: BlogIndex },
            { path: "**", redirectTo: "Blog" },
        ]
  },
  { path: "", component: About,
       data: {
          meta: {
            title: 'About',
            description: 'Description of about'
          }
        },
        children:[
            { path: "", component: AboutIndex },
            { path: "**", redirectTo: "About" }
        ]
  },
  { path: "**", redirectTo: "About" }
];

export const appRouterProviders = [
  provideRouter(routes)
];

universal-cli and ng2-meta issue

i get this error and not sure why:
Error encountered resolving symbol values sta tically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported fu nction, resolving symbol AppModule in C:/xampp/htdocs/universaltest3/src/app/app.browser.module.ts, resolving symbol Ap pModule in C:/xampp/htdocs/universaltest3/src/app/app.browser.module.ts
and before i use ng2-meta i could go to source code and see the page. after i only get:
`<!doctype html>

<title>Universaltest3</title> <script src="http://localhost:35729/livereload.js?snipver=1"></script> Loading... <script type="text/javascript" src="inline.bundle.js"></script><script type="text/javascript" src="vendor.bundle.js"></script><script type="text/javascript" src="client.bundle.js"></script> `

Angular 7

We would love if you could update the package to depend upon Angular 7. Thanks!

Router optional?

Would it be possible to use this module without the Router dependency? My app doesn't use routing but I have a need for using this module to dynamically update meta tags per page ( I have to use a CMS that uses a back end).

SEO does not work with ng2-meta in SPA

I have tried implementing this in my application and as well i have tried to see the updated title and description in facebook post with the different route urls of the demo application.

http://vinaygopinath.github.io/ngMeta/#/download

In the facebook post i have tried using below urls

  1. http://vinaygopinath.github.io/ngMeta/#/download
  2. http://vinaygopinath.github.io/ngMeta/#/
  3. http://vinaygopinath.github.io/ngMeta/#/example/dynamic-tags

For all the three url's i could see same title and description in the preview
screen shot 2016-12-21 at 12 47 39 pm

Please help us understanding whether we are expecting which is not supported by this library or we are missing some thing.

Thanks in Advance,
Phani

[Question] Use with ionic2

Can I use ng2-meta in an application made with ionic2? If the answer is yes, it's because I'm trying here, and it's giving this error

captura de tela de 2017-01-17 17 06 46

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.