第1个回答 2014-12-18
JS代码:
!function (global) {
var mod = angular.module('test.bg', []);
mod.controller('bgController', ['$scope', function ($scope) {
$scope.div1Bg = '#ffffff';
$scope.div2Bg = '#ffffff';
$scope.changeBg = function () {
$scope.div2Bg = $scope.div1Bg;
};
}]);
}(this);
HTML代码:
<body ng-controller="bgController">
<div style="background-color: {{div1Bg}}" ng-click="changeBg()">div1</div>
<div style="background-color: {{div2Bg}}">div2</div>
</body>本回答被提问者采纳