欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

angular實現(xiàn)導(dǎo)航菜單切換

 更新時間:2022年03月25日 14:03:32   作者:maoer9999  
這篇文章主要為大家詳細介紹了angular實現(xiàn)導(dǎo)航菜單切換,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了angular實現(xiàn)導(dǎo)航菜單切換的具體代碼,供大家參考,具體內(nèi)容如下

js部分: 

$scope.navArr=[{
? ? ? ? task:{
? ? ? ? ? ? title: "我的任務(wù)",
? ? ? ? ? ? showAdd: true,
? ? ? ? ? ? data:[
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? title:'我的設(shè)計院',
? ? ? ? ? ? ? ? ? ? id:1,
? ? ? ? ? ? ? ? ? ? hasChild:false,
? ? ? ? ? ? ? ? ? ? active:true,
? ? ? ? ? ? ? ? },
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? title:'我加入的設(shè)計院',
? ? ? ? ? ? ? ? ? ? id:2,
? ? ? ? ? ? ? ? ? ? hasChild:true,
? ? ? ? ? ? ? ? ? ? active:false,
? ? ? ? ? ? ? ? ? ? data:[
? ? ? ? ? ? ? ? ? ? ? ? {title:"設(shè)計院1",active:true},
? ? ? ? ? ? ? ? ? ? ? ? {title:"設(shè)計院2",active:false}
? ? ? ? ? ? ? ? ? ? ]
? ? ? ? ? ? ? ? },
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? title:'驗證消息',
? ? ? ? ? ? ? ? ? ? id:3,
? ? ? ? ? ? ? ? ? ? hasChild:false,
? ? ? ? ? ? ? ? ? ? active:false,
? ? ? ? ? ? ? ? },
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? title:'我參與的設(shè)計院',
? ? ? ? ? ? ? ? ? ? id:3,
? ? ? ? ? ? ? ? ? ? hasChild:true,
? ? ? ? ? ? ? ? ? ? active:false,
? ? ? ? ? ? ? ? ? ? data:[
? ? ? ? ? ? ? ? ? ? ? ? {title:"設(shè)計院3",active:true},
? ? ? ? ? ? ? ? ? ? ? ? {title:"設(shè)計院4",active:false}
? ? ? ? ? ? ? ? ? ? ]
? ? ? ? ? ? ? ? },
? ? ? ? ? ? ]
? ? ? ? }
? ? ? ? }];
? ??
? ? $scope.showItem=false;
? ? $scope.showId=null;
? ? //給菜單項添加事件
? ? $scope.changNavMenu=function(item,arr,hasChild){
? ? ? ? for(let i of arr){
? ? ? ? ? ? if(i==item){
? ? ? ? ? ? ? ? i.active=true;
? ? ? ? ? ? ? ? showNav(hasChild,i.id)
? ? ? ? ? ? }else{
? ? ? ? ? ? ? ? i.active=false;?
? ? ? ? ? ? }
? ? ? ? }
? ? }
? ? function showNav(hasChild,id){
? ? ? ? if($scope.showId!=id){
? ? ? ? ? ? $scope.showItem=false;
? ? ? ? ? ? $scope.showId=id;
? ? ? ? }
? ? ? ? if(hasChild){
? ? ? ? ? ? if($scope.showItem==false){
? ? ? ? ? ? ? ? $scope.showItem=true
? ? ? ? ? ? }else if($scope.showItem==true){
? ? ? ? ? ? ? ? $scope.showItem=false
? ? ? ? ? ? }
? ? ? ? }
? ? }
? ? // 給二級菜單添加點擊事件
? ? $scope.changTwoNav=function(item,arr){
? ? ? ? for(let i of arr){
? ? ? ? ? ? if(i==item){
? ? ? ? ? ? ? ? i.active=true;
? ? ? ? ? ? }else{
? ? ? ? ? ? ? ? i.active=false;?
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? event.stopPropagation();
? ? }

html片段:

<div class="two_level_box">
? <!-- title -->
? <p class="menu-title">{{navArr[0].task.title}}</p>
? <!-- add -->
? <div class="add-pro-btn" ng-if="navArr[0].task.showAdd">
? ? <span>+ 快速立項</span>
? </div>
? <!--一級菜單-->
? <ul class="navMenu">
? ? <li ng-click="changNavMenu(item,navArr[0].task.data,item.hasChild)" ng-class="{active:item.active}" ng-repeat="item in navArr[0].task.data">
? ? ? <a href=""><b ng-class="{b_active:showItem&&item.active}" ng-if="item.hasChild"></b> {{item.title}}</a>
? ? ? <ul class="subMenu closeSubMenu" ng-class="{true:'subMenu',false:'closeSubMenu'}[showItem&&item.active]">
? ? ? ? <li ng-if="item.hasChild" ng-class="{active:i.active&&item.active}" ng-click="changTwoNav(i,item.data)" ng-repeat="i in item.data">
? ? ? ? ? ? <a href="">{{i.title}}</a>
? ? ? ? </li>
? ? ? </ul>
? ? </li>
? </ul>
? </ul>
</div>

css:

.two_level_box{
? float:left;
? width: 139px;
? height: 100%;
? background: #fff;
}
.menu-title{
? margin:10px;
}
.add-pro-btn{
? cursor: pointer;
? margin:10px;
}
.add-pro-btn span{
? display: inline-block;
? width:100%;
? text-align: center;
? border:1.5px solid #EE6133;
? border-radius: 20px;
? padding:2px;
? color:#EE6133;
}
.navMenu>li>a{
? margin:8px 0;
? padding:10px;
}
.navMenu>li{
? margin:8px 0;
? padding:0;
}
.navMenu li a{
? color:#000;
}
.navMenu>.active>a{
? color:#EE6133;
}
.subMenu .active{
? background-color: #FACFC1;
? border-right:2px solid #EE6133;
}
.closeSubMenu{
? display: none;
}
.subMenu li{
? padding:5px 0;
? border-right:2px solid #fff;
}
.subMenu li a{
? padding-left:30px;
}
.navMenu b{
? display: inline-block;
? width:8px;
? height:0;
? border-left:5px solid #A9A9A9;
? border-top:4px solid transparent;
? border-bottom:4px solid transparent;
}
.navMenu .b_active{
? border-top:5px solid #A9A9A9;
? border-left:4px solid transparent;
? border-right:4px solid transparent;
}

實現(xiàn)效果圖:

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • AngularJS學(xué)習(xí)筆記之依賴注入詳解

    AngularJS學(xué)習(xí)筆記之依賴注入詳解

    下面小編就為大家?guī)硪黄狝ngularJS學(xué)習(xí)筆記之依賴注入詳解。小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2016-05-05
  • AngularJS路由切換實現(xiàn)方法分析

    AngularJS路由切換實現(xiàn)方法分析

    這篇文章主要介紹了AngularJS路由切換實現(xiàn)方法,結(jié)合具體實例形式分析了AngularJS路由切換的實現(xiàn)步驟與相關(guān)操作技巧,需要的朋友可以參考下
    2017-03-03
  • 教你用AngularJS框架一行JS代碼實現(xiàn)控件驗證效果

    教你用AngularJS框架一行JS代碼實現(xiàn)控件驗證效果

    簡單來說Angular.js是google開發(fā)者設(shè)計和開發(fā)的一套前端開發(fā)框架,幫助你簡化前端開發(fā)的負擔(dān)。到底能簡化到什么程度呢,今天我們來看下,一行代碼實現(xiàn)控件驗證效果,有木有嚇尿?
    2014-06-06
  • Angularjs注入攔截器實現(xiàn)Loading效果

    Angularjs注入攔截器實現(xiàn)Loading效果

    angularjs作為一個全ajax的框架,對于請求,如果頁面上不做任何操作的話,在結(jié)果反回來之前,頁面是沒有任何響應(yīng)的,不像普通的HTTP請求,會有進度條之類
    2015-12-12
  • 詳解AngularJS中module模塊的導(dǎo)入導(dǎo)出

    詳解AngularJS中module模塊的導(dǎo)入導(dǎo)出

    本文給大家介紹angularjs中module模塊的導(dǎo)入導(dǎo)出,涉及到angularjs module相關(guān)知識,對angularjs module感興趣的朋友一起看看吧
    2015-12-12
  • AngularJS實現(xiàn)動態(tài)添加Option的方法

    AngularJS實現(xiàn)動態(tài)添加Option的方法

    這篇文章主要介紹了AngularJS實現(xiàn)動態(tài)添加Option的方法,涉及AngularJS事件響應(yīng)及頁面元素動態(tài)操作相關(guān)實現(xiàn)技巧,需要的朋友可以參考下
    2017-05-05
  • Angular實現(xiàn)的日程表功能【可添加及隱藏顯示內(nèi)容】

    Angular實現(xiàn)的日程表功能【可添加及隱藏顯示內(nèi)容】

    這篇文章主要介紹了Angular實現(xiàn)的日程表功能,帶有向日程表中添加內(nèi)容及隱藏顯示內(nèi)容的功能,涉及AngularJS事件響應(yīng)及頁面元素動態(tài)操作相關(guān)實現(xiàn)技巧,需要的朋友可以參考下
    2017-12-12
  • 詳解Angular 4.x Injector

    詳解Angular 4.x Injector

    本篇文章主要介紹了Angular 4.x Injector,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-05-05
  • Angular中使用Api 代理的實現(xiàn)

    Angular中使用Api 代理的實現(xiàn)

    我們對接的過程中總是遇到跨域的問題,本文使用 angualr 來講解代理api對接的話題,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2022-04-04
  • Angularjs 自定義服務(wù)的三種方式(推薦)

    Angularjs 自定義服務(wù)的三種方式(推薦)

    angularjs 中可通過三種($provider,$factory,$service)方式自定義服務(wù)。這篇文章主要介紹了Angularjs 自定義服務(wù)的三種方式,非常不錯,需要的朋友可以參考下
    2016-08-08

最新評論