jjj jjj - 1 month ago 32
TypeScript Question

Angular 2 HTTP Service (Youtube API)

I am new to this, so please excuse if I am not getting something obvious here.

Here is the project on Github, if you want to give it a try: https://git.io/vXtWp

Anyhow, I have a simple Angular 2 service that calls YouTube Api, it looks like this:

enter image description here

Then I have an app.component.ts that looks like this:
enter image description here

And HTML file:

enter image description here

My application doesn't work though, it shows as loading with following error:

Uncaught Error: Can't resolve all parameters for FormControl: (?, ?, ?). metadata_resolver.js:499


This is what it looks like in the browser:
enter image description here

Any ideas what I am doing wrong? I've spent 2 hours, having no luck figuring this issue out...

Answer
<input [FormControl]="search">

should be

<input [formControl]="search">
        ^

This needs to be the selector or input name of a directive or component, not the class name.

FormControl should be removed from imports: [...] in @NgModule(). Only modules should be listed in imports of @NgModule() not individual classes.

There is no need to list ReactiveFormsModule in providers. Adding it to import is enough.

Comments