zoukankan      html  css  js  c++  java
  • 自己定义一个tab指令

    定义一个tab切换的指令:

    指令的文件结构

    Js/directives/tab

    tab.html

    tab.js

    tab.html:
    <style>
        .my-li-style{
            line-height: 30px;
            margin-right: 10px;
            border-radius: 3px;
            height:30px;
            cursor: pointer;
        }
        .tabactive{
            color: #fff;
            background:#f48a36;
        }
    </style>
    <div class="amdin-nav">
        <ul class="list-inline adminAction-listHeader">
            <li class="my-li-style" ng-repeat="tab in tab_list" 
           ng-click="tab_click(tab.state)"
                ng-class={tabactive:current_state==tab.state}
                ui-sref="{{tab.state}}">{{tab.name}}</li>
        </ul>
    </div>
    Tab.js:
    define(["app"],function(myapp){
        myapp.directive('mytab',["$state",function($state){
            return {
                scope:{
                    data:"="
                },
                templateUrl:'js/directives/tab/tab.html',
                link:function(s,ele,attrs){
                    s.current_state=$state.current.name;//初始化(获得当前的路由状态)
                    s.tab_click=function(cstate){//每次触发此事件,就传递过来状态值
                        s.current_state=cstate;
                    }
                   s.$watch("data",function(n_data){//监听值的改变
                    s.tab_list=n_data;
                  })
                }
            };
        }]);
    });
    控制器:
    //创意界面的权限控制器
    define(["app",'services/zct_get_my_right','directives/tab/tab'], function (myapp) {
        myapp.controller('ideas_first_ctrl',
            ['$scope','$rootScope','$state','get_my_right', function (s,rs,$state,getRight) {           
           var my_right=getRight.get_right(localStorage.permission);
                s.idea_tab=[
                    {name:"全部创意",state:"home.ideas.allIdeas"},
                    {name:"我的创意",state:"home.ideas.myIdeas"},
                ];
            }])
    });
    Html:
    <div class="ideas-list">
        <div class="my-row">
    
         	<mytab  data="idea_tab"></mytab>
    
            <div class=" list-content"  ui-view="part" ></div>
        </div>
    </div>
    

      

  • 相关阅读:
    让Oracle的 SHOW PARAMETER 命令显示隐藏参数
    insufficient privileges for 'SYS' when 'shutdown immediate'
    ROW_NUMBER
    Oracle RAC 环境下的连接管理
    git报错:fatal: bad config line 1 in file C:/Users/JIANGXIAOLIANG/.gitconfig
    MVC教程:授权过滤器
    MVC教程:MVC区域路由
    ES6语法:let和const
    git基本操作:分支管理
    Vue:计算属性
  • 原文地址:https://www.cnblogs.com/evaling/p/6803614.html
Copyright © 2011-2022 走看看