Dependency injection

Writing Angular in TypeScript demands that your building blocks (components, directives, services, and so on) are written in classes. They are just building blocks, which means that they need to be intertwined with each other before they can become functional, thus making a full-blown application.

This intertwining process can be pretty daunting. For this reason, let's understand the problem first. Take the following TypeScript class, for instance:

export class Developer {  private skills: Array<Skill>;  private bio: Person;  constructor() { = new Person('Sarah', 'Doe', 24, 'female');    this.skills = [      new Skill('css'),       new Skill('TypeScript'),       new Skill('Webpack')    ];  }}

The implementation of the Person and Skill ...

Get TypeScript 2.x for Angular Developers now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.