Angularjs   发布时间:2022-04-20  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了angularjs中的选项卡实例大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
angularjs中的bug
ng-click,赋值,ng-repeat三个一起用会有bug


一个angularjs的选项卡
<!DOCTYPE html>
<html>
<head>
    <Meta charset="utf-8" />
    <title>angularjs中的选项卡</title>
    <script src="https://cdn.staticfile.org/angular.js/1.5.5/angular.min.js"></script>
  
    <style>
          .Box input.active{
              BACkground:yellow
          }
          .Box div{
              width:200px;
              height:200px;
              BACkground:#CCC;
              border:1px solid black;
              display:none
          }
            .Box div.cur {
                 display:block;
            }
    </style>
</head>

<!--angularjs中的bug
ng-click,赋值,ng-repeat三个一起用会有bug-->
<body ng-app="tab_switch">
    <div ng-controller="test">
        <div class="Box">
            <input type="button" ng-repeat="(k,v) in items" value="{{k}}" class="{{$index==Now?‘active‘:‘‘}}" ng-click="setNow($indeX)" />


            <!--angularjs中的bug
    ng-click,赋值,ng-repeat三个一起用会有bug-->
            <!--<input type="button" ng-repeat="(k,v) in items" value="{{k}}" class="{{$index==Now?‘active‘:‘‘}}" ng-click="Now=$index" />-->

            <div class="{{$index==Now?‘cur‘:‘‘}}" ng-repeat="v in items">
                {{v}}
            </div>

        </div>
    </div>

    <script type="text/javascript">
        let mod = angular.module("tab_switch",[]);
        mod.controller("test",["$scope",function ($scopE) {
            $scope.Now = 0;
            $scope.items = {
                "按钮1": "ssssds","按钮2": "ddddd","按钮3":"fffff"
            };


            $scope.setNow = function (num) {
                $scope.Now = num;
            }
               
        }]);
    </script>

</body>
</html>

大佬总结

以上是大佬教程为你收集整理的angularjs中的选项卡实例全部内容,希望文章能够帮你解决angularjs中的选项卡实例所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。