AngularJS中ng-class样式如何切换
这篇文章主要介绍AngularJS中ng-class样式如何切换,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
创新互联主要从事成都网站制作、成都网站设计、网页设计、企业做网站、公司建网站等业务。立足成都服务永善,十载网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:18980820575
1、HTML
FirstSecondThird
AllFirstSecondThird
2、controller
appControllers.controller('TestlCtrl', function ($scope, $state) { $scope.isFirst = false; $scope.isSecond = false; $scope.isThird = false; $scope.hasAll = false; $scope.hasFirst = false; $scope.hasSecond = false; $scope.hasThird = false; $scope.toggleAll = function () { $scope.hasAll = !$scope.hasAll; console.log($scope.hasAll); var dynamicValue = $scope.hasAll; $scope.hasFirst = dynamicValue; $scope.hasSecond = dynamicValue; $scope.hasThird = dynamicValue; } $scope.toggleFirst = function () { $scope.hasFirst = !$scope.hasFirst; checkAll(); } $scope.toggleSecond = function () { $scope.hasSecond = !$scope.hasSecond; checkAll(); } $scope.toggleThird = function () { $scope.hasThird = !$scope.hasThird; checkAll(); } function checkAll() { if ($scope.hasFirst == true && $scope.hasSecond == true && $scope.hasThird == true) { console.log("123ok"); $scope.hasAll = true; } else { console.log("123no"); $scope.hasAll = false; } } })
3、效果图
4、循环列表,判断索引添加样式
*、
合作 {{item.VendorName}}
以上是“AngularJS中ng-class样式如何切换”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注创新互联行业资讯频道!
文章题目:AngularJS中ng-class样式如何切换
URL网址:http://azwzsj.com/article/gpcjhg.html