加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs中的选项卡实例

发布时间:2020-12-17 07:04:44 所属栏目:安全 来源:网络整理
导读:angularjs中的bugng-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" / s
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>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读