在angularjs中添加自定义元标记

时间:2015-02-09 07:02:06

标签: angularjs meta-tags

我正在为布局页面添加自定义元标记



<meta name="description" content="{{metaDiscription}}"/>
&#13;
&#13;
&#13;

在控制器中:

&#13;
&#13;
$scope.metaDiscription = "adding custom discription";
&#13;
&#13;
&#13;

并在&#34;查看页面来源&#34;中查看它,它显示在抓取工具中的元内容(不评估角度抓取)。 如何更新angularjs中的元标记,这些元标记可以显示在&#34;查看页面源&#34;页面?

这是我的完整代码:

&#13;
&#13;
var app = angular.module('app',[]);
app.directive(
        'customMetaTag',
        function() {
            return {
                restrict: "E",
                template: '<meta name="description" content="{{metaDescription}}"></meta>',
                replace: true,
                link: function(scope) {
                    scope.metaDescription = 'adding custom discription';
                }
            }


        }
    )
&#13;
<!DOCTYPE html>
<html ng-app="app">
<head>
  <title>Title</title>
  <meta charset='utf-8'/>
  <custom-meta-tag></custom-meta-tag>
</head>

<body>

 

</body>

</html>
&#13;
&#13;
&#13;

0 个答案:

没有答案