Oh, wow...nevermind. Removing the parameter from the constructor fixes everything. Thanks.
On Wed, Nov 18, 2015 at 12:49 PM, Mark Rathwell <[email protected]> wrote: > Thanks, Eric. I really think this is something specific to using ng-for > here. If I factor out the ng-for stuff everything works as expected, and > the property is successfully passed to the child component from the parent > component. In this case, I want to pass the property from the ng-for > context, but it does not seem to be working. > > I have seen examples that show passing ng-for values to a custom > component, but I cannot find examples of the actual component > implementation. Using @Optional() in the child component constructor did > stop the error, but the property value that I am trying to pass is null in > the constructor. > > What should the component implementation look like to accept a property > from ng-for as in <component-two *ng-for="#foo of foos" > [foo]="foo"></component-two> > > > > On Wed, Nov 18, 2015 at 7:46 AM, Eric Martinez <[email protected]> > wrote: > >> Mark, >> >> when you do this >> >> directives: [ComponentTwo, NgFor] >> >> Angular tries to instatiate the class, but it can not find any provider >> for "String" (note that in your constructor you are passing a string, so it >> assumes your ComponentTwo it has a dependency [provider,viewProvider] that >> is type of String). So I recommend two things >> >> - Remove it and use Parent/Child communication to set the value for "foo" >> - Try adding @Optional() in your constructor (I've read that it only >> works with classes, so probably won't work, just give it a try ;) ) >> >> Another thing I noticed is the order of your classes/components, if the >> snippet your pasted is the same in your project it should be fail in >> another way : note that "ComponentTwo" is defined after "ComponentOne", so, >> again, assuming that's the order in your classes you should add this to >> your directives property >> >> directives: [forwardRef(() => ComponentTwo), NgFor] >> >> Reference >> https://angular.io/docs/ts/latest/api/core/forwardRef-function.html >> Forward references in Angular2 >> <http://blog.thoughtram.io/angular/2015/09/03/forward-references-in-angular-2.html> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "AngularJS" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To post to this group, send email to [email protected]. >> Visit this group at http://groups.google.com/group/angular. >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
