Reputation: 14100
Goal:
Make a connection with service named Data in stackblitz.
Problem:
It doesn't work. what part am I missing?
Stackblitz:
https://stackblitz.com/edit/angular-mpy6pr
Thank you!
Upvotes: 0
Views: 1129
Reputation: 15423
There are two problems:
Import the HttpClientModule in your app.module.ts
import { HttpClientModule } from "@angular/common/http";
@NgModule({
imports: [BrowserModule, FormsModule, HttpClientModule],
...
})
Next fix the import in app.component.ts
import { DataService } from './_services/data.service';
Upvotes: 2
Reputation: 754
https://stackblitz.com/edit/angular-ytzk2a?file=src/app/app.component.ts
You were missing this part, you need to reference the file not just the folder:
Upvotes: 0