angularjs set page title

Use below code to dynamically set page title depending on your state or route:

in app.js

...
...
.state('signup', {
            url: "/signup",
            controller: 'SignUpCtrl',
            templateUrl: 'views/signup/signUp.html',
            pageTitle: 'SignUp'
        });
...

app.run(function($rootScope, $state) {
  $rootScope.$on('$stateChangeStart', function(event, current) {
      $rootScope.pageTitle = current.pageTitle;
   })
});

in html:

<html ng-app="app"> 
 <head> 
 <title>{{ pageTitle }}</title>
 ... 

1 comment: