Reputation: 11
I have a directive dewQtip
in qtip.directive.ts which basically does the same thing as ngbTooltip directive along with some customizations that are to be maintained in the entire organization ecosystem. In the directive, I am manually triggering the tooltip to open :
this.ngbToolTip.open();
But right above this I am setting the ngbToolTip
as:
this.ngbToolTip = new NgbTooltip(
this._elementRef,
this._renderer,
this.injector,
this.viewContainerRef,
this.ngbTooltipConfig,
this.ngZone,
document,
this._cdRef,
this._appRef
);
And this is where the error generates from.
Error: NG0203: inject() must be called from an injection context such as a constructor, a factory function, a field initializer, or a function used with runInInjectionContext
. Find more at here
The error seems to stem from
export function ngbPositioning() {
const rtl = inject(NgbRTL);
So it goes from,
export function ngbPositioning() {
const rtl = inject(NgbRTL);
in positioning.ts
^
^
private _positioning = ngbPositioning();
in tooltip.ts
^
^
this.ngbToolTip = new NgbTooltip(.....)
in /qtip.directive/
Have created a minimal reproduction with the custom directive in question. Reproduction Link
Angular: 16.1.7
ng-bootstrap: 15.1.2
Bootstrap: 5.2.3
Still investigating.
I tried downgrading to the previous versions of @ng-bootstrap/ng-bootstrap (since the issue itself was faced after ng upgrade 11 --> 16) but these versions are not supported by angular 16 anymore. Yet to find any workarounds so far.
Upvotes: 1
Views: 77