Javascript 一个视图的多个控制器angularjs

Javascript 一个视图的多个控制器angularjs,javascript,angularjs,controller,Javascript,Angularjs,Controller,我想知道是否可以使用angluarjs为一个url视图使用多个控制器,我还没有找到太多关于这方面的文档。我想在所有页面上使用控制器来切换页面标题,但有些页面已经包含控制器 app.js subscriptionApp.config(['$routeProvider',function($routeProvider){ $routeProvider. when('/billinginfo',{templateUrl:'views/billing-info.html', controller:'bi

我想知道是否可以使用angluarjs为一个url视图使用多个控制器,我还没有找到太多关于这方面的文档。我想在所有页面上使用控制器来切换页面标题,但有些页面已经包含控制器

app.js

subscriptionApp.config(['$routeProvider',function($routeProvider){
$routeProvider.
when('/billinginfo',{templateUrl:'views/billing-info.html', controller:'billingInfoController'}).
when('/orderreview',{templateUrl:'views/order-review.html', controller:'billingInfoController'}).
when('/subscribed',{templateUrl:'views/subscribed.html', controller:'subscribedTitle'}).

//EXAMPLE: HOW COULD I ADD TWO CONTROLLERS TO SAME PAGE??? THIS DOES NOT WORK
when('/subscribe',{templateUrl:'views/subscribe.html', controller:'subscriptionController', 'testControllerTitle'}).

when('/unsubscribed',{templateUrl:'views/cancelconfirm.html', controller:'unsubscribedTitle'}).
when('/redirectBack',{templateUrl:'views/redirect-to-app.html'}).
when('/redirectHandler',{templateUrl:'views/redirect-handler.html',controller:'redirectController'}).
when('/error',{templateUrl:'views/error.html', controller:'messageController'}).
otherwise({redirectTo:'/subscribe'});
}]);
编辑 我正在尝试向每个页面视图添加标题控制器:

function testControllerTitle($rootScope, $scope, $http) { $rootScope.header = "Success!"; }
如果我将此控制器添加到还没有控制器的页面中,它就可以工作,如果有另一个控制器,我就无法工作

<h1 ng-bind="header"></h1>

是,控制器和模板是独立的,请检查此项


为什么不让一个控制器作为标头模板的一部分,并使用服务来更新它?大概是这样的:
var app = angular.module("App", ['ngRoute']);

app.config( function ( $routeProvider ) {
  $routeProvider
  .when('/a', {templateUrl: 'this.html', controller: "aCtrl"})
  .when('/b', {templateUrl: 'this.html', controller: "bCtrl"})
  .when('/c', {templateUrl: 'that.html', controller: "bCtrl"})
  .otherwise({redirectTo: '/a'});
});

app.controller('aCtrl', function ($scope) {
    $scope.all = [1,2,3];
});

app.controller('bCtrl', function ($scope) {
    $scope.all = [4,5,6];
});