nativescript-vue / nativescript-vue-navigator

A simple router for NativeScript-Vue, built on top of $navigateTo to simplify routing from within components

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cant access added meta on page

MohammedBashiru opened this issue · comments

`export const routes = {
'/login': {
component: Login
},
'/tm-root': {
component: Root,
meta: { needsAuth: true, page_title: "Home" }
},
'/tour-manager-home': {
component: TourManagerHome,
meta: { needsAuth: true, page_title: "Home" }
},

}`

But when I tried to get a computed property of the page name is resulted in

TypeError: Cannot read property 'meta' of undefined

console.log("page_title", this.$navigator.route.meta.page_title)

I had the same problem myself. I guess you are calling this.$navigator.route.meta.page_title OUTSIDE of the <Navigator /> component (like in your root app for example).

I was able to acces it this way:

($navigator.route && $navigator.route.meta && $navigator.route.meta.page_title)

Hi @Jonarod Thanks for the reply.
Yes I need to call it outside the <Navigator /> because I need to display the page title on the parent component.

I have not tried this yet because am away from computer. Can you please confirm this will work outside the <Navigator /> component. ?

($navigator.route && $navigator.route.meta && $navigator.route.meta.page_title)

Thanks

Ok thanks @Jonarod I will try it again when I get back to the project.

Thanks @Jonarod It worked.

I just found out the hack does NOT work on iOS...

I just found out the hack does NOT work on iOS...

That sucks. Thanks for letting me know

Hey @dantanie I was able to get current page name on iOS using:

this.$navigator.path

hope it helps