angular-ui-router路由备忘

<script src="plugins/angular/angular.js"></script>
<script src="plugins/angular/angular-ui-router.min.js"></script>

html:

首页

 <ol class="head-bottom-nav" nav-Li>
            <li ><a ui-sref="collecttotall" >数据总览</a></li>
             <li><a ui-sref="collect-application">应用数据</a></li>
             <li><a ui-sref="repottatol.repotdata" >上报数据</a></li>
             <li><a ui-sref="exdata">外部数据</a></li>
     </ol>

二级页面

 <div class="right-content" >
<div class="col-lg-4">
            <ul class=" repotnewcss-nav" secendnav-Li>
         <li class="on"><a ui-sref="repottatol.repotdata">旅游景区</a></li>
         <li><a ui-sref="repottatol.repotdata1">旅游商品</a></li>
         <li><a ui-sref="repottatol.repotdata2">旅游餐饮</a></li>
      </ul>
       <div ui-view="view1"></div>
       

</div>
<div class="col-lg-4">
            <ul class=" repotnewcss-nav" secendnav-Li>
         <li class="on"><a ui-sref="repottatol.repotdata">酒店客栈</a></li>
         <li><a ui-sref="repottatol.repotdata1">农家乐</a></li>
         <li><a ui-sref="repottatol.repotdata2">旅游商品</a></li>
      </ul>
       <div ui-view="view2"></div>
       

</div>
<div class="col-lg-4">
            <ul class=" repotnewcss-nav" secendnav-Li>
         <li class="on"><a ui-sref="repottatol.repotdata">旅行社</a></li>
         <li><a ui-sref="repottatol.repotdata1">旅游交通</a></li>
         <li><a ui-sref="repottatol.repotdata2">旅游休闲</a></li>
      </ul>
       <div ui-view="view3"></div>
       

</div>
    
    </div>

js:

 // JavaScript Document
 app.config(function($stateProvider,$urlRouterProvider) {
    $urlRouterProvider.otherwise('/collecttotall');
    $stateProvider.state('collecttotall', {
        url:'/collecttotall',
        templateUrl:'collecttotall.html',
        controller: function(){
           setCookie("id","0"); 

        }   
    }).
    state('collect-application', {
        url:'/collect-application',
        templateUrl: 'collect-application.html',
        controller: function(){
             setCookie("id","1"); 
            
        }            
      
    }).
    state('repottatol', {
        url:'/repottatol',
        templateUrl: 'repottatol.html',
        controller: function($state){
             setCookie("id","2"); 
              $state.go('repottatol.repotdata'); 
        }   
      
    }).
    state('exdata', {
        url:'/exdata',
        templateUrl: 'exdata.html',
        controller: function(){
             setCookie("id","3"); 
        }   
        
      
    }).
    state('repottatol.repotdata', {
        views:{
          'view1':{
          url:'/repotdata',
          templateUrl:'repot1.html',
           
           },
           'view2':{
           url:'/repotdata',
           templateUrl:'repot2.html',
          },
            'view3':{
            url:'/repotdata',
           templateUrl:'repot3.html',
          
           }}
           
      
    }).
    state('repottatol.repotdata1', {
        views:{
          'view1':{
          url:'/repotdata1',
           templateUrl:'repot4.html',
         },
           'view2':{
           url:'/repotdata1',
           templateUrl:'repot5.html',
           },
            'view3':{
            url:'/repotdata1',
           templateUrl:'repot6.html',
          }
           }
           
      
    }).
    state('repottatol.repotdata2', {
        views:{
          'view1':{
          url:'/repotdata2',
           templateUrl:'repot7.html'},
           'view2':{
           url:'/repotdata2',
           templateUrl:'repot8.html',
           },
            'view3':{
            url:'/repotdata2',
           templateUrl:'repot9.html',
          }
           }
           
      
    })
});

选中js

 /*********************导航*******************/

app.directive('navLi',['$rootScope','navServer', function($rootScope,navServer) {
    return  function($scope, element, attrs) {
               var i= getCookie("id"); 
               element.children().eq(i).addClass("active").siblings("li").removeClass("active");
               element.children().click(function(){
                   $(this).addClass("active").siblings("li").removeClass("active");
                    })
        }
        }]);
/*******************二级导航****************/

app.directive('secendnavLi', function() {
    return  function($scope, element, attrs) {
              
             
               element.children().click(function(){
                   $(this).addClass("on").siblings("li").removeClass("on");
                   
                   })
        }
});

           

转载于:https://my.oschina.net/u/3101682/blog/1558799

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Element-UI 是一个基于 Vue.js 的 UI 组件库,如果要在 Angular 中使用 Element-UI,需要先安装 Vue.js,并且在 Angular 中集成 Vue.js。 具体步骤如下: 1. 安装 Vue.js 在 Angular 项目中安装 Vue.js,可以使用 npm 命令进行安装: ``` npm install vue --save ``` 2. 安装 Element-UI 在 Angular 项目中安装 Element-UI,同样可以使用 npm 命令进行安装: ``` npm install element-ui --save ``` 3. 集成 Vue.js 在 Angular 中集成 Vue.js,可以使用 ngx-build-plus 插件。在 Angular 项目中安装 ngx-build-plus: ``` npm install ngx-build-plus --save-dev ``` 然后在 angular.json 文件中配置 ngx-build-plus: ``` "architect": { "build": { "builder": "ngx-build-plus:browser", "options": { "extraWebpackConfig": "./extra-webpack.config.js" }, "configurations": { "production": { "extraWebpackConfig": "./extra-webpack.config.js" } } } } ``` 在 extra-webpack.config.js 文件中配置 Vue.js 的 loader: ``` const VueLoaderPlugin = require('vue-loader/lib/plugin') module.exports = { module: { rules: [ { test: /\.vue$/, loader: 'vue-loader' }, { test: /\.js$/, loader: 'babel-loader' } ] }, plugins: [ new VueLoaderPlugin() ] } ``` 4. 在 Angular 中使用 Element-UI 在 Angular 中使用 Element-UI,需要先在组件中引入 Vue.js 和 Element-UI: ``` import Vue from 'vue' import ElementUI from 'element-ui' Vue.use(ElementUI) ``` 然后在组件中使用 Element-UI 的组件: ``` <template> <el-button>Button</el-button> </template> <script> export default { name: 'MyComponent' } </script> ``` 这样就可以在 Angular 中使用 Element-UI 了。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值