我正在使用Angularjs 1.5。Angularjs 1.5 ng控制器<head>標籤
創建一個服務來處理META數據和頁面標題。 試圖應用它。
的問題是 - 由於某種原因,如果我直接在<head>
標籤定義一個控制器:
<head ng-controller="headMetaController">
控制器將根本不會被加載,但如果我把它包在附加<div>
withing的<head>
:
<head>
<div ng-controller="headMetaController">
<title ng-bind="seoMetaService.title()"></title>
<meta name="description" content="{{ seoMetaService.metaDescription() }}">
<meta name="keywords" content="{{ seoMetaService.metaKeywords() }}">
<div>
</head>
=>它的工作原理。
所以,我想它以某種方式連接,尤其是<head>
標記=>不確定,解決它的正確方法是什麼? 我也擔心把元數據放在額外的<div>
之內可能對於搜索引擎優化目標來說不是個好主意嗎?
你正在做什麼? – Ved
將'ng-controller'移動到''標籤。你將在該標籤上同時具有'ng-app'和'ng-controller'。 – Lex