0
こんにちは私の要件では、メタタグコンテンツを動的に更新したいと考えています。コンテンツはのインスペクタエレメントで正常に更新されましたが、ビューソースページに更新されたコンテンツが表示されませんでした。ビューのソースページのメタタグをdynammicで更新したいこの要件を解決するために私を助けてください。私のコードを見てください。私はGoogleでこのコードを見つける。私はビューのソースページでメタタグを更新する必要がありますか?ビューソースページの動的メタタグangularjs
<html ng-app="app">
<title ng-bind="metaservice.metaTitle()">Test</title>
<meta name="description" content="{{ metaservice.metaDescription() }}" />
<meta name="keywords" content="{{ metaservice.metaKeywords() }}" /><script>var app = angular.module('app',[]);
app.service('MetaService', function() {
var title = 'Web App';
var metaDescription = '';
var metaKeywords = '';
return {
set: function(newTitle, newMetaDescription, newKeywords) {
metaKeywords = newKeywords;
metaDescription = newMetaDescription;
title = newTitle;
},
metaTitle: function(){ return title; },
metaDescription: function() { return metaDescription; },
metaKeywords: function() { return metaKeywords; }
}
});app.controller('myCtrl',function($scope,$rootScope,MetaService){
$rootScope.metaservice = MetaService;
$rootScope.metaservice.set("Web App","desc","blah blah");});</script><body ng-controller="myCtrl"></body></html>
申し訳ありませんが、それは今、別の質問になりました。トピックの完全に外です:)なぜメタタグを更新したいのですか?また、あなたが説明することができます_ビューのソースページが更新されていないGoogleは検索目的のために私のウェブサイトメタタグのコンテンツを取る方法_? –
それを残す。あなたの助けをありがとう – chaitanay
これがあなたを助けてくれたら、あなたは** upvote **と**答えを受け入れることができます** ..ハッピーコーディング.. –