如何基于AngularJS部分视图动态更改标头?
<html data-ng-app="myModule"><head><!-- include js files --><title><!-- should changed when ng-view changes --></title></head><body><h1> <!-- should changed when ng-view changes --></h1><div data-ng-view></div></body></html>
var myModule = angular.module('myModule', []);myModule.config(['$routeProvider', function($routeProvider) { $routeProvider. when('/test1', {templateUrl: 'test1.html', controller: Test1Ctrl}). when('/test2', {templateUrl: 'test2.html', controller: Test2Ctrl}). otherwise({redirectTo: '/test1'});}]);function Test1Ctrl($scope, $http) { $scope.header = "Test 1"; /* ^ how can I put this in title and h1 */ }function Test2Ctrl($scope, $http) { $scope.header = "Test 2"; }
皈依舞
相关分类