1

There are other answers that show how to set a HTML title in AngularJS. This is my variation which works for basic cases even while using angular-translate:

<title ng-controller="PageCtrl" ng-bind-template="MyApp: {{title}}"></title>

and

angular.module('MyApp')
    .controller('PageCtrl', function($rootScope, $translate) {

        $rootScope.$on('$stateChangeStart', function(event, toState) {
            $translate('title').then(function(translated) {
                $rootScope.title = translated;
            });
        })

    })

This works if the translation string is plain text like "My Title", but fails when there are angular variables like in "My {{something}}" because - I think - the scope doesn't have the something variable set even if I set $scope.something in another Controller.

So I think the question is how can I make sure the scope will contain the variables set in say MainCtrl?

Community
  • 1
  • 1
Col Wilson
  • 889
  • 10
  • 16

0 Answers0