• AngularJs1.X学习--路由


    【三种使用说明:】

    $stateProvider.state('station.printQRCode', {
                    //params: { 'parentOfficeId': null }, //一次性参数---printQRCode
                    //url: '/printQRCode?:parentOfficeId', //URL参数--printQRCode?parentOfficeId=1
                    url: '/printQRCode/:parentOfficeId', //URL参数--printQRCode/1 
                    templateUrl: '~/App/station/views/stationsmanagement/printQRCode.cshtml'
                });
    • params: { 'parentOfficeId': null }        (http(s)://*****/printQRCode)

           使用这种方式,路由到的目标页面,只能在第一次加载的时候获取到参数值;一刷新页面,该参数值就不存在了! 

    • url: '/printQRCode?:parentOfficeId'       (http(s)://*****/printQRCode?parentOfficeId=10)
    • url: '/printQRCode/:parentOfficeId'       (http(s)://*****/printQRCode/10)

    【html页面中使用:】

      <a ui-sref="station.printQRCode({parentOfficeId:{{vm.pOfficeId}}})"><i class="fa fa-plus"></i> @L("PrintQRCode")</a>

    【Js文件中获取参数的方式:】

    (function () {
        appModule.controller('cdode', [
            '$scope', '$stateParams',function ($scope, $stateParams) {            
             vm.parentOfficeId = ($stateParams.parentOfficeId || ""); //获取参数
     } ]); 
    })();

    注意:多参数后续遇到再补充:)

  • 相关阅读:
    P2155 [SDOI2008]沙拉公主的困惑
    P4345 [SHOI2015]超能粒子炮·改
    乘法逆元
    P1608 路径统计
    P1342 请柬
    一些网址
    20/08/02测试
    ivqBlog 开源博客 (angularjs + express + mongodb)
    angularjs, nodejs, express, gulp, karma, jasmine 前端方案整合
    参照nopCommerce框架开发(NextCMS)
  • 原文地址:https://www.cnblogs.com/lishidefengchen/p/7055144.html
Copyright © 2020-2023  润新知