我计划使用AngularJS 1.x动态更改元标题,Meta关键字和元描述,以反映在Facebook,Twitter,Google Plus和LinkedIn中。
有没有办法动态改变?我正在使用REST Api调用。
谢谢, -Venkat
答案 0 :(得分:1)
我建议您使用Tristan建议的this库。它工作得很好。并且还与动态表达式兼容。
要更新元标记,您只需在视图中使用以下标记:
<update-title title="A new title"></update-title>
<update-meta charset="ISO-8859-1"></update-meta>
<update-meta http-equiv="Content-Language" content="es"></update-meta>
<update-meta name="description" content="A page specific description"></update-meta>
<update-meta property="og:title" content="Minions"></update-meta>
<update-meta itemprop="description" content="A page specific itemprop description"></update-meta>
您可以使用以下命令安装它:
bower install angular-update-meta
希望它会对某人有所帮助。
答案 1 :(得分:0)
使用Angular-update-meta,它将帮助您动态更新元标记。
答案 2 :(得分:0)
您可以使用ng-bind
动态创建任何代码的内容。
例如:
<title ng-bind="pageTitle()"></title>
然后在你的控制器中:
$scope.pageTitle = function () {
return 'the page title you want to add dynamically';
};
Google现在呈现javascript,因此动态页面标题和元标记将被正确编入索引。
答案 3 :(得分:0)