利用angularjs实现,点击一个div区域会将该div的背景颜色传给另一个div,从而改变其背景颜色

2024-11-05 02:34:05
推荐回答(1个)
回答1:

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代码:

div1

div2