pkberlin
pkberlin

Reputation: 852

Angular expression in title tag in internet explorer 8 not working

I want to display a title rendered via angular. It works fine in browsers like chrome or firefox and also in internet 9 and 10.

The ng-app is defined in the html tag.

The title tag looks like this:

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

Can anyone help me please? Do you need more informations about the app?

Upvotes: 3

Views: 1474

Answers (3)

Maxence
Maxence

Reputation: 13296

You can use $window.document.title to set your title without binding.

Upvotes: 5

Thomas Vo
Thomas Vo

Reputation: 402

This is the cross browser solution. ng-bind and ng-bind-template would never work because they use element.text(), which never works with on IE8.

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

Upvotes: 1

Golo Roden
Golo Roden

Reputation: 150624

You have to use:

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

Alternatively you may also use ng-bind, but ng-bind-template has the additional advantage that it allows you to have multiple {{}} expressions within.

Upvotes: 1

Related Questions