Since most people are going to be writing Angular 2 using TypeScript, they probably won't run into this error. If you use TypeScript, the combination of Angular 2 decorators and typed constructor arguments will do the work of decorating parameters for you (forgive me if I'm misusing some of the terminology here). But, if you're experimenting with writing Angular 2 in ES5 (like I am), you have to configure the component parameters yourself. And, if you ever forget to "new" your Inject() metadata:
WidgetComponent.parameters = [ ng.core.Inject( ng.core.ElementRef ) ];
... you will get the following error:
EXCEPTION: No provider for ParamDecorator! (Widget -> ParamDecorator)
Here, we are treating Inject() as if it were just a method, when in reality, it's a constructor function. To fix this, all we have to do is add the "new" operator:
WidgetComponent.parameters = [ new ng.core.Inject( ng.core.ElementRef ) ];
As I've been digging into Angular 2 Beta 1, I've tripped over this a number of times, especially when I'm knee-deep in solving a totally different problem. So, I figured I'd make a record of it incase anyone also runs into the error and tries to Google for the error message.
Looking For A New Job?
- Software Development Engineer - REQ20003869 at Express Scripts
- Mobile Application Developer at Xorbia Tickets
- 7 Year + Lead ColdFusion Developer at Atprime Media Services
- Full Time ColdFusion Developer Needed at InterCoastal Net Designs
- Developer-focused job platform at Honeypot