2013-03-26 40 views
3

我想要顯示通過角度呈現的標題。它適用於Chrome或Firefox等瀏覽器以及互聯網9和10.在Internet Explorer 8中的標題標記中的角度表達不起作用

ng-app在html標記中定義。

標題標籤看起來是這樣的:

<title>  
{{resultListQuery.selectedPropertiesSummary}} in {{resultListQuery.geoCodingResult.locationName}} 
</title> 

誰能幫助我嗎?你需要更多關於應用程序的信息嗎?

+0

最壞的情況下可能會從控制器更改標題=>'angular.element( '標題')。文本(VAR1 + '在' + VAR2)' – charlietfl 2013-03-26 11:16:35

回答

0

你必須使用:

<title ng-bind-template="foo {{pageTitle}} bar"></title> 

另外,您也可以使用ng-bind,但ng-bind-template具有額外的優勢,它可以讓你有內的多個{{}}表達式。

+0

不要爲我 – Maxence 2014-06-25 14:13:19

+0

工作,我已經修復了一個錯字,請你再試一次嗎? – 2014-06-25 14:17:07

+0

不要使用ng-bind和ng-bind-template – Maxence 2014-06-26 18:42:26

5

您可以使用$window.document.title來設置您的標題沒有綁定。

+0

這是不幸的這個答案有一個負面評論,當它實際上唯一的一個是正確的! {{...}}在IE8中失敗(以及ng-bind-template或ng-bind)來更新頭文件,但是$ window.document.title可以在所有瀏覽器中使用。 – 2014-06-27 12:09:11

1

這是跨瀏覽器的解決方案。 ng-bind和ng-bind-template將永遠不會工作,因爲它們使用element.text(),它永遠不會在IE8上工作。

myModule.run(function($interpolate, $window) { 
    ... 
    $rootScope.$watch(function() { 
     return $interpolate(myTitleTemplate)($myScope); 
    }, function(title) { 
     $window.document.title = title; 
    }) 
    ... 
}); 
相關問題