Dependency injection

Dependency injection(DI), or Inversion of Control (IoC), is a very useful and common software design pattern. This pattern is used to inject objects into the objects that depend on them. The object you're using that depends on other objects can just go ahead and use it without needing to worry where it is in order to load it, or how to instantiate it—you just use it as if it just sprung into existence at the time you needed it. Services are perfect for injecting into our application. We'll learn how to use DI in Angular, and how we can use the Angular command-line interface (CLI ) to generate injectable services of our own design.

Just before we move on to setting up our development environment, here are some interesting things about Angular:

  • AngularJS was built using JavaScript, while Angular was built using TypeScript. While this adds a level of abstraction when writing Angular applications, using TypeScript provides a few important advantages when building larger apps with larger teams—we'll get to those shortly.
  • AngularJS was based on controllers, whereas Angular is component based. You'll learn all you need to know about components in Chapter 6, Building Angular Components.
  • SPAs are notorious for being difficult for implementing Search Engine Optimization (SEO ), but Angular is SEO friendly.
  • It's possible to build native mobile applications with Angular.
  • It's also possible to build cross-platform, desktop-installed applications with Angular.
  • Angular can also run on the server, using Angular Universal.

You have to admit, this is a pretty impressive and exciting list. These things and more make learning Angular a worthwhile endeavor and the marketplace is asking for Angular know-how.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.76.138