zoukankan      html  css  js  c++  java
  • angularui 自定义选项卡

    ng-include 选取ng-template

    <!DOCTYPE html>
    <html lang="en" ng-app="myApp">
    <head>
        <meta charset="UTF-8">
        <title>tabs</title>
        <link rel="stylesheet" href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css">  
        <script src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
        <script src="http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js"></script>
        <style>
            .active{display:block;}
            .sec{background:red;}
            .tabpanel{display: none;}
            .head{}
            .head .tul{list-style:none;padding:0;}
            .head .tul .tli{float:left;padding:10px 20px;}
            .head .tul .tli .ta{text-decoration: none; color:#000;display:block;}
        </style>
        <script>
            angular.module('myApp',[]).controller("tabsCtrl",function($scope){
                $scope.tabs=[{head:'选项卡1',content:'list.html',active:true},{head:'选项卡2',content:'选项卡2的内容',active:false},{head:'选项卡3',content:'选项卡3的内容',active:false}];
                $scope.changeTab=function($index){
                    for(var i=0;i<$scope.tabs.length;i++)
                    {
                        $scope.tabs[i].active=false;
                    }
                    $scope.tabs[$index].active=true;
                };
                $scope.items=['hehehehe','shishi','uiuiui']
            })
        </script>
    </head>
    <body>
        <div ng-controller="tabsCtrl">
            <div class="head">
                <ul class="tul clearfix">
                    <li class="tli" ng-repeat="tab in tabs"><a href="javascript:;" class="ta" ng-class="{sec:tab.active}" ng-click="changeTab($index)">{{tab.head}}</a></li>
                </ul>
            </div>
            <div class="tab-content">
                <div class="tabpanel" ng-repeat="tab in tabs" ng-class="{active:tab.active}" ng-include="tab.content"></div>
            </div>
            
        </div>
        <script type="text/ng-template" id='list.html'>
            <ul>
                <li ng-repeat="item in items">{{item}}</li>
            </ul>
        </script>
        
    </body>
    </html>
  • 相关阅读:
    hdu4998 旋转坐标系
    hdu4998 旋转坐标系
    hdu5012 水搜索
    hdu5012 水搜索
    hdu5007 小水题
    ZOJ 3645 BiliBili 高斯消元 难度:1
    ZOJ 3654 Letty's Math Class 模拟 难度:0
    ZOJ 3647 Gao the Grid dp,思路,格中取同一行的三点,经典 难度:3
    ZOJ 3646 Matrix Transformer 二分匹配,思路,经典 难度:2
    ZOJ 3644 Kitty's Game dfs,记忆化搜索,map映射 难度:2
  • 原文地址:https://www.cnblogs.com/tonghaolang/p/5972898.html
Copyright © 2011-2022 走看看