[英]how to change Meta Title,Meta Keywords,Meta Description dynamically in AngularJs 1.x?
我计划使用AngularJS 1.x动态更改元标题,Meta关键字和元描述,以反映在Facebook,Twitter,Google Plus和LinkedIn中。
有没有办法动态改变? 我正在使用REST Api调用。
谢谢,-Venkat
我建议你使用Tristan建议的这个库。 它工作得很好。 并且还与动态表达式兼容。
要更新元标记,您只需在视图中使用以下标记:
<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
希望它会帮助某人。
使用Angular-update-meta,它将帮助您动态更新元标记。
您可以使用ng-bind
动态创建任何标记的内容。
例如:
<title ng-bind="pageTitle()"></title>
然后在你的控制器中:
$scope.pageTitle = function () {
return 'the page title you want to add dynamically';
};
Google现在呈现javascript,因此动态页面标题和元标记将被正确编入索引。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.