Using IRouteContext in plain JS

Hi, I’m using router-lite and I’d like to use the navigation model in my component in a plain-JS Au2 app. In the docs it says to do:

export class NavBar {
  private readonly navModel: INavigationModel;
  public constructor(@IRouteContext routeCtx: IRouteContext) {
    this.navModel = routeCtx.navigationModel;
  }

  public async binding() {
    await this.navModel.resolve()
  }
}

I can’t figure out how to do the equivalent of @IRouteContext routeCtx: IRouteContext in my constructor. I’ve tried @injecting IRouteContext directly, using both newInstanceOfand newInstanceForScope, etc. but I get errors that (I think) indicate that it’s not registered for injection (e.g., AUR0012).

What’s the proper way to use a navigation model from plain JS?

1 Like

Maybe something like this?

import { IRouteContext } from '@aurelia/router-lite'
import { inject } from 'aurelia'

@inject(IRouteContext)

export class MyComponent {
  constructor(routeCtx) {
    this.routeCtx = routeCtx;
  }
}