Angular ui route stateparam in substate

随声附和 提交于 2020-01-07 04:51:13

问题


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

This is my 'master' state

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

And this is my substate:

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

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

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

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

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.


回答1:


try this: ui-router documentation

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


来源:https://stackoverflow.com/questions/42254388/angular-ui-route-stateparam-in-substate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!