码迷,mamicode.com
首页 > 其他好文 > 详细

Angular数据绑定调色板

时间:2017-08-18 14:39:37      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:height   调色板   asc   turn   char   run   src   doctype   html   

<!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数据绑定调色板

标签:height   调色板   asc   turn   char   run   src   doctype   html   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!