The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

Share Services and Data with Angular 2 Dependency Injection

Share Services and Data with Angular 2 Dependency Injection

1:22
The Angular CLI generates Services using a simple command. After your Service is generated, you can easily provide and share it to the rest of your application using Angular 2's Dependency Injection. This lesson walks through creating a Service with the Angular CLI then providing it to your application module.
Watch this lesson now
Avatar
egghead.io

Using Services in Angular 2 is very simple. This lesson covers how to create a simple class as a Service then set it up so that you can use it across all your Components.

Avatar
Oleksandr

This video should go after 'Inject a service' in the playlist.

In reply to egghead.io
Avatar
Oleksandr

Whoops, I meant 'Using the @Inject decorator' should go after this one.

In reply to Oleksandr
Avatar
sebastian

hi, what editor or ide ar you using, i saw you got helped on the import statement for @injectable

In reply to egghead.io
Avatar
cube5

I think its WebStorm

In reply to sebastian
Avatar
leaf

I'm getting an error "main.ts:12Uncaught Error: Module build failed: Error:..." after editing 'providers: [MailService],' at app.module.ts, and it didn't automatically imported for me. How can I fix it ?

Avatar
Cekootje

How comes that when generating a service, ng puts the files right in the app root folder? And creating a component showed that it gets generated inside its own folder. Are there guiding lines for this that ng is following?

HEY, QUICK QUESTION!
Joel's Head
Why are we asking?