JavaScript Edu Resources. Angular Courses. React Tutorials. Join us!

The Core Concepts of Angular 2

  • In this blog post I will talk about the three core concepts of Angular 2: components, dependency injection, and bindings.Let’s Build an AppLet’s say we want to build this application, which is a list of tech talks that you can filter, watch, and rate.ComponentsTo build an Angular 2 application you define a set of components, for every UI element, screen, and route.
  • And TalkCmp is an item in that list.To understand what constitutes a component in Angular 2, let’s look closer at and Output PropertiesA component has input and output properties, which can be defined in the component decorator or using property decorators.Data flows into a component via input properties.
  • For instance, this component will be notified when its input properties change.ProvidersA component can contain a list of providers the component and its children may inject.In this example, we have the backend and the logger services declared in the root component, which makes them available in the whole application.
  • Angular 2 aims to provide a higher-level API, so the native platform, the DOM, will just reflect the state of the Angular application.This is useful for a couple of reasons:It makes components easier to refactor.It allows unit testing most of the behavior of an application without touching the DOM.
  • Angular 2 provides such APIs, but our hope is that you will rarely need to use them.Components are Self-DescribingWhat I have listed constitutes a component.A component knows how to interact with its host element.A component knows how to render itself.A component configures dependency injection.A component has a well-defined public API of input and output properties.All of these make components in Angular 2 self-describing, so they contain all the information needed to instantiate them.



The Core Concepts of Angular – Angular



Comments are closed, but trackbacks and pingbacks are open.