How to put page title according to a product using JS?

1

My problem is in trying to put information in the title, in the description or swap the page image by java script. I am trying to make a shopping page (e-commerce) with angular and on the product page I would like to modify the title, description and image according to the product that is on the page, so far so good, but when I send the link gives page in whatsapp or facebook they can not get the title changed by angular. Can anyone help me ??

An example:

    
asked by anonymous 10.10.2017 / 21:49

2 answers

0

You can not send information via client-side (JavaScript) scripts to external sites that try to pull the information from your site. This is because sites like Facebook, for example, will pick up the HTML information from your site and will not process the scripts.

What should be done is that such information should come from your server directly to your HTML.

Example in PHP:

<title><?php echo $titulo_da_pagina; ?></title>
    
10.10.2017 / 23:18
1

Hello, in order for facebook and whatsapp to better understand the information on your page you should add the OpenGraph meta tags in the head of your application.

Open Graph allows site developers to turn their sites into a graphical object allowing for a certain level of customization of a recommended, tanned or simply shared page.

<meta property="og:locale" content="pt_BR">

<meta property="og:url" content="http://www.meusite.com.br/ola-mundo">

<meta property="og:title" content="Título da página ou artigo">
<meta property="og:site_name" content="Nome do meu site">

<meta property="og:description" content="Minha boa descrição para intrigar os usuários.">

<meta property="og:image" content="www.meusite.com.br/imagem.jpg">
<meta property="og:image:type" content="image/jpeg">
<meta property="og:image:width" content="800"> /** PIXELS **/
<meta property="og:image:height" content="600"> /** PIXELS **/

/** CASO SEJA UM SITE NORMAL **/

<meta property="og:type" content="website">

/** CASO SEJA UM ARTIGO **/

<meta property="og:type" content="article">
<meta property="article:author" content="Autor do artigo">
<meta property="article:section" content="Seção do artigo">
<meta property="article:tag" content="Tags do artigo">
<meta property="article:published_time" content="date_time">

More information you can get at link

In order to be able to answer you better, it is interesting that you change your question with more information ... which version of angular is working and show us a bit of how you are doing these changes with JS.

    
10.10.2017 / 22:39