I am currently facing an issue while trying to inject RouterService into my controller:
import Controller from '@ember/controller';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';
import RouterService from '@ember/routing/router-service';
export default class Search extends Controller.extend({
// anything which *must* be merged to prototype here
}) {
@service router!: RouterService;
@action
actionClick(){
this.router.transitionTo('protected.apk.detail')
}
}
// DO NOT DELETE: this is how TypeScript knows how to look up your controllers.
declare module '@ember/controller' {
interface Registry {
'search': Search;
}
}
Unfortunately, I encountered an error message that reads:
Error: Assertion Failed: Attempting to inject an unknown injection: 'service:router'
It seems like the correct syntax should be router:main instead of service:router.
Could you please provide guidance on how I can properly inject RouterService?
Please note that this controller is part of my engine.
Ember version: 3.18.0
Your help is greatly appreciated.