Skip to content

dynamic routes support #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kabaluyot opened this issue Apr 6, 2020 · 5 comments
Closed

dynamic routes support #35

kabaluyot opened this issue Apr 6, 2020 · 5 comments

Comments

@kabaluyot
Copy link

No description provided.

@rigor789
Copy link
Member

rigor789 commented Apr 6, 2020

What do you mean by dynamic routes? What would they solve that's not already possible?

@kabaluyot
Copy link
Author

kabaluyot commented Apr 6, 2020

Like in vue router, we can provide and create a dynamic route by passing it in params:

e.g

/social:id or /social/{id}

and passing id lets say 24415 will give us:

/social/24415

Example:
in my index.ts, I specify the routes:

import Home from "@/views/Home.vue";
import Categories from "@/views/Categories.vue";

export const routes = {
  '/home': {
    component: Home,
    meta: {
      title: "Home"
    }
  },
  '/categories:id': { .   // -> this is dynamic route with id passed on call as params
    component: Categories,
    meta: {
      title: "Categories",
    }
  },
}

@rigor789
Copy link
Member

rigor789 commented Apr 6, 2020

Navigator is intentionally simple - you can achieve the same thing by passing in the id as a prop.

this.$navigator.navigate(`/categories', { props: { id: 1234 } })

@kabaluyot
Copy link
Author

Hmm, I think I made myself confused. The question should be intended to generate a dynamic page and the navigator can just pass it like your example. Thank for your time and sorry :)

@mreall
Copy link

mreall commented Jun 16, 2020

Dynamic routes would be particularly helpful for apps that consume a web API. My Vue web app can receive a dynamic route from the API and route to a page that processes the parameters from the URL. Any component on the rendered page can then read the URL to access the parameters.

With Navigator, when I get a URL from the API, I have to convert it to a Navigator path with props, then pass the props from parent component to child component. This makes it harder to share nativescript components with the web app and more complicated to share the URL parameters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants