I have the following html
<!doctype html> <html lang="en" data-ng-app="AlexsApp"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>{{$scope.title}}</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> <link rel="stylesheet" href="assets/css/site.min.css"> </head> <body> <!-- Site Navigation area --> <nav class="navbar navbar-inverse navbar-fixed-top transparent"> <div class="container-fluid"> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-navbar-collapse-1" aria-expanded="false"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="#/"> <img src="assets/img/alex_logo_sm.png" alt="Alex Pittendreigh's Logo"> </a> </div> <div class="collapse navbar-collapse" id="bs-navbar-collapse-1"> <ul class="nav navbar-nav"> <li> <a href="#/contact">Contact</a> </li> </ul> </div> </div> </nav> <!-- Main content area --> <div class="container" data-ng-view> </div> <!-- Site Footer navigation --> <nav class="hidden-xs navbar navbar-inverse navbar-fixed-bottom transparent"> <div class="container-fluid"> <p id="footer-text">Copyright © 2015 Alex Pittendreigh. All rights reserved.</p> </div> </nav> <!-- Site script files --> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.4/angular.min.js"> </script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.4/angular-route.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> <script src="assets/js/site.js"></script> </body> and the following javascript file
var app = angular.module('AlexsApp', ['ngRoute']); app.config(function($routeProvider) { $routeProvider. when('/', { controller: 'HomeCtrl', templateUrl: 'assets/partials/home.html' }). when('/contact', { controller: 'ContactCtrl', templateUrl: 'assets/partials/contact.html' }). otherwise({ redirectTo: '#/' }); }); app.controller('HomeCtrl', function($scope, $http) { $scope.title='Alex Pittendreigh'; }); app.controller('ContactCtrl', function($scope, $http) { $scope.title='Contact Alex Pittendreigh'; }); The other two files are simple HTML content that gets loaded when a new route is selected in Angular.
My problem is that I want to change the page title when a route changes and this is not happening. Instead I tend to get the route displayed as a title.
I have tried several sources on StackOverflow and looked through the documentation but haven;t actually found a solution that works for me.
Can anyone help please?
<title>{{title}}</title>,$scopeis implicit in angular views.