nativescript-vue / nativescript-vue-navigator

A simple router for NativeScript-Vue, built on top of $navigateTo to simplify routing from within components
MIT License
98 stars 10 forks source link

Cant access added meta on page #7

Closed MohammedBashiru closed 5 years ago

MohammedBashiru commented 5 years ago

`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)

Jonarod commented 5 years ago

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)
MohammedBashiru commented 5 years ago

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

Jonarod commented 5 years ago

Well it works outside the Navigator component for me :)

On Wed, May 15, 2019, 23:38 Mohammed Bashiru notifications@github.com wrote:

Hi @Jonarod https://github.com/Jonarod Thanks for the reply. Yes I need to call it outside the 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 component. ?

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

Thanks

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nativescript-vue/nativescript-vue-navigator/issues/7?email_source=notifications&email_token=ABOWZT2FYV5NB27EIN3CPRDPVR7G3A5CNFSM4HM3SLO2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVQAWEI#issuecomment-492833553, or mute the thread https://github.com/notifications/unsubscribe-auth/ABOWZT3WSU6B7LC6BSAPTO3PVR7G3ANCNFSM4HM3SLOQ .

MohammedBashiru commented 5 years ago

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

MohammedBashiru commented 5 years ago

Thanks @Jonarod It worked.

Jonarod commented 5 years ago

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

MohammedBashiru commented 5 years ago

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

That sucks. Thanks for letting me know

Jonarod commented 5 years ago

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

this.$navigator.path

hope it helps

MohammedBashiru commented 5 years ago

Wow, thanks. I really appreciate the support.

Regards.

Mohammed Bashiru Multi-Platform Software Engineer

Mobile: +233 546 891 427

Email: mohammedbashiru63@gmail.com mohammedbashiru63@gmail.com

Website: https:iammohammedb.com mohammedbashiru63@gmail.com

Code-In Ghana

               https://iammohammedb.com/register

KS-Ltd Key Beverage Distributor in Ghana

FOODS-INN[image: Logo (2)]

                Ghana Limited

SIMU-DRIVE

                Ghana Limited

On Fri, 31 May 2019 at 19:05, Jonarod notifications@github.com wrote:

Hey @dantanie https://github.com/dantanie I was able to get current page name on iOS using:

this.$navigator.path

hope it helps

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nativescript-vue/nativescript-vue-navigator/issues/7?email_source=notifications&email_token=AIU2HT4KYLA4LG54OQUDYXDPYFZGJA5CNFSM4HM3SLO2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWWDVYQ#issuecomment-497826530, or mute the thread https://github.com/notifications/unsubscribe-auth/AIU2HTYB2SB5BPBDOKBWXSLPYFZGJANCNFSM4HM3SLOQ .