子状态中的 Angular ui 路由 stateparam [英] Angular ui route stateparam in substate

查看:10
本文介绍了子状态中的 Angular ui 路由 stateparam的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在子状态中使用 stateparam 时遇到一些问题.

I have some issues with using a stateparam in a substate.

这是我的主人"状态

.state("shop", {
    abstract: true,
    url: '/shop/:nameSlug',
    templateUrl: '/views/shop/index.html',
    controller: 'shopController',
    params: {
        nameSlug: null,
        }
    })

这是我的子状态:

.state('shop.payment-success', {
    url: '/payment-success?transactionid',
    templateUrl: '/views/payment-success.html',
    controller: 'checkoutController'
})

我想在我的控制器中使用参数transactionid",但是当我记录它时,它是未定义的.

I want to use the param 'transactionid' in my controller, but when I log it, it's undefined.

我尝试过 $stateParams 和 $state.params,但它们之间没有区别.

I have tried with $stateParams and $state.params, but there is no difference between them.

有没有办法在checkoutController"中使用transactionid?

Is there a way to make transactionid available in 'checkoutController'?

供您参考:参数 ?transactionId 来自支付网关,我无法更改它.它包含 orderId,这是我进行真实付款支票所需要的.

For your information: the param ?transactionId is coming from a payment gateway and I can't change it. It contains the orderId, what I have been needed for a check for a genuine payment.

推荐答案

试试这个:ui-router 文档

.state('shop.payment-success', {
    url: '/payment-success',
    params: {
          transactionid: null
    }  
    templateUrl: '/views/payment-success.html',
    controller: 'checkoutController'
})

这篇关于子状态中的 Angular ui 路由 stateparam的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆