#ng-class和ng-style <!DOCTYPEhtml> <html> <head> <Metacharset="UTF-8"> <title></title> <scripttype="text/javascript"src='js/angular.min.js'></script> <styletype="text/css"> .ng-cloak{display:none;} .red{background:red;} .yellow{background:yellow;} </style> </head> <bodyng-app="hd"ng-cloakclass="ng-cloak"> <divng-controller="ctrl"> <table> <tr> <td><inputtype="checkBox"ng-checked="status"ng-model="status"/>{{status}}</td> <td>{{status?"取消":"全选"}}</td> </tr> <trng-repeat="vindata"> <td><inputtype="checkBox"ng-checked="status"/>{{status}}</td> <!--ng-class样式根据数据动态变化--> <!--ng-style自定义样式--> <td><divng-class="status?'red':'yellow'"ng-style="{fontSize:size+'px'}">{{v}}</div></td> </tr> </table> 文字大小:<inputtype="text"ng-model="size"/> </div> <scripttype="text/javascript"> varm=angular.module('hd',[]) m.controller('ctrl',['$scope',function($scope){ $scope.status=true $scope.data=['game','coding','card'] }]) </script> </body> </html>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。