#ng-class和ng-style <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <script type="text/javascript" src='js/angular.min.js'> </script> <style type="text/css"> .ng-cloak{display:none;} .red{background: red;} .yellow{background: yellow;} </style> </head> <body ng-app="hd" ng-cloak class="ng-cloak"> <div ng-controller="ctrl"> <table> <tr> <td><input type="checkbox" ng-checked="status" ng-model="status" />`status`</td> <td>{{status?"取消":"全选"}}</td> </tr> <tr ng-repeat="v in data" > <td><input type="checkbox" ng-checked="status" />`status`</td> <!--ng-class 样式根据数据动态变化--> <!--ng-style 自定义样式--> <td><div ng-class="status?'red':'yellow'" ng->`v`</div></td> </tr> </table> 文字大小: <input type="text" ng-model="size" /> </div> <script type="text/javascript"> var m=angular.module('hd',[]) m.controller('ctrl',['$scope',function($scope){ $scope.status=true $scope.data=['game','coding','card'] }]) </script> </body> </html>
本文标题:angularjs-更改样式ng-class,ng-style
分享链接:https://www.cdcxhl.com/article32/iieopc.html
成都网站建设公司_创新互联,为您提供用户体验、域名注册、Google、云服务器、移动网站建设、企业网站制作
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联