Search code examples
angularsyncfusionangular11treegrid

Syncfusion TreeGrid + Angular 11 "Error: inject() must be called from an injection context"


I wanted to use Syncfusion TreeGrid in my Angular solution but when I imported module and added it to component I'm getting following error:

core.js:6210 ERROR Error: Uncaught (in promise): Error: inject() must be called from an injection context
Error: inject() must be called from an injection context
    at injectInjectorOnly (core.js:4708)
    at ɵɵinject (core.js:4718)
    at Module.ɵɵdirectiveInject (core.js:14619)
    at NodeInjectorFactory.TreeGridComponent_Factory [as factory] (ej2-angular-treegrid.js:493)
    at getNodeInjectable (core.js:3596)
    at instantiateAllDirectives (core.js:10280)
    at createDirectivesInstances (core.js:9629)
    at ɵɵelementStart (core.js:14837)
    at Module.ɵɵelement (core.js:14888)
    at TreeDemoComponent_Template (tree-demo.component.html:9)
    at resolvePromise (zone-evergreen.js:1213)
    at resolvePromise (zone-evergreen.js:1167)
    at zone-evergreen.js:1279
    at ZoneDelegate.invokeTask (zone-evergreen.js:406)
    at Object.onInvokeTask (core.js:28540)
    at ZoneDelegate.invokeTask (zone-evergreen.js:405)
    at Zone.runTask (zone-evergreen.js:178)

I'm sure it's not issue with my project configuration because same occurs when trying to run Sync fusion example.

Building on following Angular version:

Angular CLI: 11.2.6
Node: 15.5.0
OS: win32 x64
Package Version

@angular-devkit/architect 0.1102.6 (cli-only)
@angular-devkit/core 11.2.6 (cli-only)
@angular-devkit/schematics 11.2.6 (cli-only)
@schematics/angular 11.2.6 (cli-only)
@schematics/update 0.1102.6 (cli-only)

Solution

  • If found temoporary worakroud by adding following "paths" entry for compilerOptions in tsconfig.app.json

     "paths": {
      "@angular/*": [
        "./node_modules/@angular/*"
      ]
    }