Angular - Routes and Forms - Handson.txt - Course Introduction In this course Angular Routes and Forms you will learn to manage dependencies of your

Angular - Routes and Forms - Handson.txt - Course...

This preview shows page 1 - 3 out of 11 pages.

Course IntroductionIn this course Angular - Routes and Forms, you will learn to:manage dependencies of your class through Dependency Injectiontalk to servers through APIsbuild Single Page Apps using routerstake user inputs through formsWhat Is Dependency Injection?Everything looks fine, but what exactly is Service and how do you define it?What is a Service?
Background image
@Inject()It is a parameter decoratorIt explicitly tells what are the dependencies of the class inside constructor parametersexport class SmartPhone {constructor (@Inject(Battery) bat){}}The same functionality can be easily achieved using TypeScript.export class SmartPhone {constructor ( bat: Battery ){}}@Injectable()It is a class decoratorThis tells Angular that this class can be used with Dependency Injector. So whenever a component is dependent on this class, Injector can create the instance of this class.@Injectable()export class SmartPhone{}Remember to add the paranthesis () in @Inject() and @Injectable()------------------Try It Out - Dependency InjectionIn contact-list.component.ts :this.contactService.getContacts().subscribe(data => this.contacts = data);In contact.service.ts :return of(this.contacts);-------------------Which of the following creates new services required by the applications?
Background image
Image of page 3

You've reached the end of your free preview.

Want to read all 11 pages?

  • Summer '17
  • World Wide Web, Hypertext Transfer Protocol, HTTP, Observables

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture