首页 > 其他 > 详细

Angular数据绑定调色板

时间:2017-08-18 14:15:10      阅读:268      评论:0      收藏:0      [点我收藏+]

<!DOCTYPE html>
<html ng-app="myapp">
<head>
<meta charset="UTF-8">
<title></title>
<script src="http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js"></script>
<style type="text/css">
.box{
width: 200px;
height: 200px;
border: solid 1px #333;
}
</style>
</head>
<body ng-controller="MainCtrl as mainctrl">
<div class="box" ng-style="mainctrl.getColor()"></div>
<p>
r:
<input type="range" min="0" max="255" ng-model="mainctrl.r" />
<input type="text" ng-model="mainctrl.r"/>
</p>
<p>
g:
<input type="range" min="0" max="255" ng-model="mainctrl.g" />
<input type="text" ng-model="mainctrl.g" />
</p>
<p>
b:
<input type="range" min="0" max="255" ng-model="mainctrl.b" />
<input type="text" ng-model="mainctrl.b" />
</p>
<script type="text/javascript">
var myapp = angular.module("myapp",[]);

myapp.controller("MainCtrl",[function(){
this.r = 88;
this.g = 88;
this.b = 88;
this.getColor = function(){
return {"background-color":"rgb(" + this.r + "," + this.g + "," + this.b +")"};
}
}]);
</script>
</body>
</html>

Angular数据绑定调色板

原文:http://www.cnblogs.com/weiluguo/p/7389135.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!