Angularjs 我可以修改模板上的外部状态吗?

Angularjs 我可以修改模板上的外部状态吗?,angularjs,templates,Angularjs,Templates,我的网站遵循以下模板: <html lang="fr" ng-app="myApp"> <head> <meta charset="UTF-8"><title>{{title}}</title> </head> <body> <navbar> // My menu and other links </

我的网站遵循以下模板:

<html lang="fr" ng-app="myApp">
    <head>
        <meta charset="UTF-8"><title>{{title}}</title>
    </head>
    <body>
        <navbar>
            // My menu and other links
        </navbar>
        <section role="main" ng-controller="car-controller">
            <ul>
                <li ng-repeat="car in car">
                    {{car.state}}
                </li>
            </ul>
        </section>  
        // Footer
    </body>
</html>    

{{title}}
//我的菜单和其他链接
  • {{car.state}
//页脚
我所有的不同页面都应该有一个不同的主部分,使用不同的控制器来管理它们


我的问题是:如何从我的所有控制器更新我的
{{title}
station,比如本例中的
car controller

您可以通过注入或不绑定任何值从控制器内部修改文档标题

angular.module('myApp')
    .controller('car-controller', function($scope, $window){
        $window.document.title = "Title from Car Controller";
});
如果需要,您可以将逻辑移动到可调用函数,这可以为您计划用于每个部分的所有控制器完成