1

I am building an SPFx angular 2 component, that has a nested child component. The child component needs to reference the current context, but if I do:

import {
  IWebPartContext
} from '@microsoft/sp-webpart-base';

with

constructor(context: IWebPartContext) {

I get:

Unhandled Promise rejection: Can't resolve all parameters for ...

Alternatively, if I do:

constructor(@Inject(context) context: IWebPartContext) {

I get:

SPComponentLoader.loadComponent: ERROR: ***Failed to load entry point from component "ffaa6a0e-9eba-40a0-bec5-226d1db53caf" (RequirementsFormWebPart). DefaultLogHandler.error @ DefaultLogHandler.js:15 Log.error @ Log.js:19 (anonymous) @ SPSystemJsComponentLoader.js:225 TraceLogger.js:69 [1487550303166][Shell.ClientSideWebPartManager] [SPWebPartErrorCode.ScriptLoadError]:: Unable to load web part WebPart.RequirementsFormWebPart.7a18b99b-78ca-4d0e-b087-189bbe751b7d,Error: ***Failed to component "ffaa6a0e-9eba-40a0-bec5-226d1db53caf" (RequirementsFormWebPart). Original error: Error loading https://component-id.invalid/ffaa6a0e-9eba-40a0-bec5-226d1db53caf_0.0.1 script resources due to: undefined. CALLSTACK:: Error

Any ideas?

Regards,

Ben

DilumN
  • 2,889
  • 6
  • 30
  • 44
webtechy
  • 101
  • 2
  • 6

2 Answers2

2

I was facing the same issue with SPFx and Angular5. Adding this inside tsconfig.js solved my issue. "emitDecoratorMetadata": true,

Ref:- Angular 2 - Can't resolve all parameters for component: (?)

Sagar S.
  • 193
  • 1
  • 4
  • 15
0

Resolved by not injecting, but rather just needed to instantiate.

      public context: IWebPartContext;

      constructor() {
        this.model = new TaxonomyModel(this.context);
      }
webtechy
  • 101
  • 2
  • 6