HelloWorld1
HelloWorld1

Reputation: 14100

Connection to Service in Stackblitz dont work

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

Answers (2)

Nicholas K
Nicholas K

Reputation: 15423

There are two problems:

  1. Import the HttpClientModule in your app.module.ts

    import { HttpClientModule } from "@angular/common/http";
    
    @NgModule({
      imports: [BrowserModule, FormsModule, HttpClientModule],
      ...
    })
    
  2. Next fix the import in app.component.ts

    import { DataService } from './_services/data.service';
    

Forked stackblitz

Upvotes: 2

Kyle Anderson
Kyle Anderson

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:

enter image description here

Upvotes: 0

Related Questions