2

Im new to Angular and Im trying to find out where Im going wrong with this and why Im getting this error.

Can't resolve all parameters for TemlComponent: (?). at syntaxError (compiler.js:1016).

I have created a working example here https://stackblitz.com/edit/angular-w8jyjs with all the pertinent files.

The code probably contains several redundant items and methods that I created while attempting to fix this. removing a;ll parameters from the constructor in teml.component.ts gets rid of the error.

Guidance to what i've done wrong here would be appreciated.

Krysta Hunt
  • 25
  • 1
  • 4

2 Answers2

3

The constructor property in Angular is meant for defining dependencies for the initialisation of your component and not for declaring a property, which explains why you're getting the error.

Consider using an @Input() instead.

Here's an updated demo.


EDIT: For more info about constructors in Angular, check out this StackOverflow question.

Edric
  • 24,639
  • 13
  • 81
  • 91
0

So this was entirely a result of my inexperience and trying to apply examples without full knowledge. I appreciate the feedback and quick answer. I was trying to use the constuctor to pass a parameter which is not the correct way in Typescript.

Krysta Hunt
  • 25
  • 1
  • 4