Angularjs Services API. Does not load TITLE when sharing link

Asked

Viewed 21 times

1

Good afternoon, I need some help finalizing a project. I have a problem that when sharing the links on social networks, the tags title, Description and etc will not load with the values returned by the API (Using Angularjs).

I believe the problem if it gives on account that Whats, Face etc, do not load the Angular or does not wait for the request, and then picks up the source code, below some prints for the best understanding along with the code:

Right: Sharing correctly on Face

Wrong: Sharing the wrong way on Face, as it is today

Version: Angularjs v1.6.1

Html code:

<!DOCTYPE html>
<html ng-app="ecApp" ng-controller="ecCtlr">
    <head>
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
      <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
      <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=0" />
      <meta name="fragment" content="!">
      <title>{{produto.nome}}</title>
      <meta name="description" content="{{produto.texto_descricao}}" />
      <script src="angular.min.js"></script>
      <script src="app.js"></script>
      <script src="factory.js"></script>
    </head>
    <body ng-init="buscaProduto(670706)" id="ecCtlr">
    </body>
</html>

Angular APP:

var api = 'http://localhost/api/';
var app = angular.module('ecApp', []);
var idLoja = 858;

app.controller('ecCtlr', function ($scope, $sce, ECProdutos) {

    $scope.buscaProduto = function(idProduto) {
        ECProdutos.buscaProduto(idLoja, idProduto).then(function (produto) {
            $scope.produto = produto;
            $scope.produtoPai = produto;
        });
    };
});

Factory:

angular.module("ecApp").factory("ECProdutos", function ($q, $http) {
    var urlClass = 'ec/produto/';
    return {
        buscaProduto: function (idLoja, idProduto) {
            var promessa = $q.defer();

            $http.get(api + '' + urlClass + 'buscaProduto/' + idLoja + '/' + idProduto).then(
                function (result) {
                    promessa.resolve(result.data);
                }
            );

            return promessa.promise;
        }
    };
});
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.