Skip to main content
Ben Nadel at CFUNITED 2010 (Landsdown, VA) with: David Lund and Ryan Jeffords and Ryan Johnson
Ben Nadel at CFUNITED 2010 (Landsdown, VA) with: David Lund Ryan Jeffords ( @ryanjeffords ) Ryan Johnson

EXCEPTION: No Provider For ParamDecorator In Angular 2 Beta 1

By
Published in

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.

Reader Comments

I believe in love. I believe in compassion. I believe in human rights. I believe that we can afford to give more of these gifts to the world around us because it costs us nothing to be decent and kind and understanding. And, I want you to know that when you land on this site, you are accepted for who you are, no matter how you identify, what truths you live, or whatever kind of goofy shit makes you feel alive! Rock on with your bad self!
Ben Nadel