zoukankan      html  css  js  c++  java
  • anuglar.js ui-router传递参数

    anuglar.js ui-router 传递参数的方法有:

    一: ui-sref 传递参数,传递一个参数的时候

    首先路有这样写:

      

    .state('edit', { //线路编辑页面
    		
    		url: '/edit?id',
    		
    		templateUrl: 'view/template/shopList/edit.html',
    		
    		controller: 'editCtrl'
    		
    	})
    

      html 页面写法为:

    <button ui-sref="edit({id:{{item.id}}})" type="button" class="btn btn-link btn-sm">编辑</button>
    {{item.id}}是动态的数据

    controller 中获取传递的参数的方法

    $state.params.id
    可以打印 $state.params 看看结果

    传递多个参数的时候:

    路由的写法为:

    .state('edit', { //线路编辑页面
            
            url: '/edit?id&page',
            
            templateUrl: 'view/template/shopList/edit.html',
            
            controller: 'editCtrl'
            
        })
    
    url: '/edit?id&page',
    需要传递多少参数,便在问号后边跟上就行

    html 页面写法为:

    <button ui-sref="edit({id:{{item.id}},page:{{item.id}}})" type="button" class="btn btn-link btn-sm">编辑</button>

    controller 中获取传递的参数的方法,还是跟以前一样。

    一:$state.go 传递参数,传递一个或者多个参数的时候(直接写多个一个和 ui-sref 一样的写法)

    路由写法

    .state('home', {
            
            url: '/home?id&page',
            
            templateUrl: 'view/home.html',
            
            controller: 'homeCtrl'
            
        })

    控制器写法:

     $state.go('home',{id: '01',page: '02'});

    接受参数的写法:

        console.log($state.params);
    接受参数的时候有两种写法都是一样的:
    $state.params.id  或者  $stateParams.id

     

  • 相关阅读:
    获取桌面路径
    Winform判断一个窗口是否以模态化方式打开
    Winform弹出子窗体
    Winform 窗体传值 利用委托 子窗体传值给父窗体
    GridView中小的应用
    GridView显示水平滚动条
    GridView中常用属性的设置
    将DevExpress GridView中的数据原样导出到Excel中
    DevExpress 16.2如何汉化
    C#使用NPOI导出Excel
  • 原文地址:https://www.cnblogs.com/haonanZhang/p/6874396.html
Copyright © 2011-2022 走看看