get a reference to the instance of the application



  • Hello
    I am new with quasar, it is possible to get a reference to the instance of the application from the router.js ( if (THIS.$ability.can(m)){ )

    router.afterEach ((to, from) => {
             const canNavigate = to.matched.some (route => {
                 for (var meta in route.meta) {
                         if (THIS.$ability.can (meta)) {
                             return true
                         }
                     }
                     return false
                 } else {
                    return true
                 }
             })



  • @jhon said in get a reference to the instance of the application:

    Hello
    I am new with quasar, it is possible to get a reference to the instance of the application from the router.js ( if (THIS.$ability.can(m)){ )

    router.afterEach ((to, from) => {
             const canNavigate = to.matched.some (route => {
                 for (var meta in route.meta) {
                         if (THIS.$ability.can (meta)) {
                             return true
                         }
                     }
                     return false
                 } else {
                    return true
                 }
             })

    Assuming your ability is initialised as a vue prototype in a boot file, then you can get it using Vue.prototype.$ability.can(...).



  • @metalsadman Thanks…😀


Log in to reply