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

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

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

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

js部分: 

$scope.navArr=[{
? ? ? ? task:{
? ? ? ? ? ? title: "我的任務(wù)",
? ? ? ? ? ? showAdd: true,
? ? ? ? ? ? data:[
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? title:'我的設(shè)計(jì)院',
? ? ? ? ? ? ? ? ? ? id:1,
? ? ? ? ? ? ? ? ? ? hasChild:false,
? ? ? ? ? ? ? ? ? ? active:true,
? ? ? ? ? ? ? ? },
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? title:'我加入的設(shè)計(jì)院',
? ? ? ? ? ? ? ? ? ? id:2,
? ? ? ? ? ? ? ? ? ? hasChild:true,
? ? ? ? ? ? ? ? ? ? active:false,
? ? ? ? ? ? ? ? ? ? data:[
? ? ? ? ? ? ? ? ? ? ? ? {title:"設(shè)計(jì)院1",active:true},
? ? ? ? ? ? ? ? ? ? ? ? {title:"設(shè)計(jì)院2",active:false}
? ? ? ? ? ? ? ? ? ? ]
? ? ? ? ? ? ? ? },
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? title:'驗(yàn)證消息',
? ? ? ? ? ? ? ? ? ? id:3,
? ? ? ? ? ? ? ? ? ? hasChild:false,
? ? ? ? ? ? ? ? ? ? active:false,
? ? ? ? ? ? ? ? },
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? title:'我參與的設(shè)計(jì)院',
? ? ? ? ? ? ? ? ? ? id:3,
? ? ? ? ? ? ? ? ? ? hasChild:true,
? ? ? ? ? ? ? ? ? ? active:false,
? ? ? ? ? ? ? ? ? ? data:[
? ? ? ? ? ? ? ? ? ? ? ? {title:"設(shè)計(jì)院3",active:true},
? ? ? ? ? ? ? ? ? ? ? ? {title:"設(shè)計(jì)院4",active:false}
? ? ? ? ? ? ? ? ? ? ]
? ? ? ? ? ? ? ? },
? ? ? ? ? ? ]
? ? ? ? }
? ? ? ? }];
? ??
? ? $scope.showItem=false;
? ? $scope.showId=null;
? ? //給菜單項(xiàng)添加事件
? ? $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
? ? ? ? ? ? }
? ? ? ? }
? ? }
? ? // 給二級(jí)菜單添加點(diǎn)擊事件
? ? $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>+ 快速立項(xiàng)</span>
? </div>
? <!--一級(jí)菜單-->
? <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;
}

實(shí)現(xiàn)效果圖:

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

相關(guān)文章

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

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

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

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

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

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

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

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

    angularjs作為一個(gè)全ajax的框架,對(duì)于請(qǐng)求,如果頁(yè)面上不做任何操作的話,在結(jié)果反回來(lái)之前,頁(yè)面是沒(méi)有任何響應(yīng)的,不像普通的HTTP請(qǐng)求,會(huì)有進(jìn)度條之類
    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)知識(shí),對(duì)angularjs module感興趣的朋友一起看看吧
    2015-12-12
  • AngularJS實(shí)現(xiàn)動(dòng)態(tài)添加Option的方法

    AngularJS實(shí)現(xiàn)動(dòng)態(tài)添加Option的方法

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

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

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

    詳解Angular 4.x Injector

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

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

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

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

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

最新評(píng)論