0

I have a state in my config.js which looks like this:

            state("link_redirect", {
                url: "/link-redirect/",
                controller: "LinkRedirectCtrl",
                title: "Redirect Link",
                params: {endpoint: null}
            });

I dont want to change the state definition in shown above, still how can I send the endpoint params in URL so that I can fetch it using $stateParams service in my controller ?

1
  • If you want something to be accessible to $stateParams you will need to add it to your url like this: url: "/link-redirect/:endpoint" Commented Jan 6, 2017 at 3:09

1 Answer 1

1

There are two ways to access state params. Send as your state definition

   state("link_redirect", {
            url: "/link-redirect",
            controller: "LinkRedirectCtrl",
            title: "Redirect Link",
            params: {endpoint: null}
        });

Access them like, $stateParams.params.endpoint

But if you want your endpoint visible in URL, you must send like

   url: "/link-redirect/:endpoint"

Remove params: {endpoint: null}

and access it like this $stateParams.endpoint

Sign up to request clarification or add additional context in comments.

2 Comments

are you sure when we have params: {endpoint: null}, we need to access like $stateParams.params.endpoint and not like $stateParams.endpoint
Yeah, I am sure. You can try and check. Where the params is the object we are passing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.