title: How to set page title with AngularJS
body: <p>I am using the following code to display page titles for each of my AngularJS app template, but whenever I try to enter an invalid URL to test the .otherwise I get the following error:</p>
  
  <pre><code>TypeError: Cannot read property 'title' of undefined
      at http://localhost/app/js/app.js:34:43
  </code></pre>
  
  <p>Below is the app.js, index.html code used:</p>
  
  <pre><code>app.js:
  
  var myApp = angular.module('myApp', ['ngRoute', 'ngSanitize']);
  myApp.config(['$routeProvider', function($routeProvider) {
  
         $routeProvider.when('/home', 
                  {     templateUrl: 'templates/index.html', 
                        controller: 'MainController',
                        title: 'Welcome to Home Page'
                  });
          $routeProvider.otherwise({
                                      redirectTo: '/home'
  
                                   });
  
  }]);
  
  
  myApp.run(['$location', '$rootScope', function($location, $rootScope) {
      $rootScope.$on('$routeChangeSuccess', function (event, current, previous) {
          $rootScope.title = current.$$route.title;
      });
  }]);
  </code></pre>
  
  <p>Index.html:</p>
  
  <pre><code>&lt;title ng-bind="title +' - MyAPP Home'"&gt; - MyApp&lt;/title&gt;
  </code></pre>
  
  <p>Please suggest</p>