1

我正在尝试实现这样的目标:

$routeProvider.when("/home", angularAMD.route({
    title: 'Home',
    templateUrl: 'views/home.html',
    controller: 'testCtrl'
}))

就像这篇关于 $routeProvider How to dynamic change header based on angularjs partial view 的帖子一样?(第二个未被接受的答案,但似乎是更好的答案)

$routeProvider.when('/', {
  title: 'Home',
  templateUrl: '/Assets/Views/Home.html',
  controller: 'HomeController'
});
4

1 回答 1

1

添加此代码below the app.config()

  app.run(['$rootScope', '$route', function($rootScope, $route) {
        $rootScope.$on('$routeChangeSuccess', function() {
            document.title = $route.current.title;
        });
    }]);

和布局视图:

<!DOCTYPE html>
<html ng-app="app">
<head>
    <title>Default title</title>

无需绑定,无需使用 {{}}。

于 2015-07-10T07:01:32.423 回答