解决方法
您实际上可以将控制器放在html级别并修改链接标记的href:
控制器:
var app = angular.module('plunker',[]); app.controller('MainCtrl',function($scope) { $scope.name = 'World'; }); app.controller('headController',function($scope) { $scope.stylePath = 'style.css' $scope.changePath = function() { $scope.stylePath='style2.css'; }; });
标记:
<!doctype html> <html ng-app="plunker" ng-controller='headController' > <head > <Meta charset="utf-8"> <title>AngularJS Plunker</title> <script>document.write('<base href="' + document.location + '" />');</script> <link rel="stylesheet" href="{{stylePath}}"> <script src="http://code.angularjs.org/1.1.4/angular.js"></script> <script src="app.js"></script> </head> <body ng-controller="MainCtrl"> Hello {{name}}! <button ng-click="changePath()">Change</button> </body> </html>