Book Image

Switching to Angular 2

By : Minko Gechev
Book Image

Switching to Angular 2

By: Minko Gechev

Overview of this book

<p>AngularJS is a JavaScript framework that makes building web applications easier. It is used today in large-scale, high-traffic websites that struggle with under-performance, portability issues, as well as SEO unfriendliness, and complexity at scale.</p> <p>Angular 2 changes that.</p> <p>It is the modern framework you need to build performant and robust web applications. “Switching to Angular 2” is the quickest way to get to grips with Angular 2 and will help you transition in to the brave new world of Angular 2.</p> <p>We’ll start with an overview which sets the changes of the framework in context with version 1.x. After that, you will be taken on a TypeScript crash-course so we can take advantage of Angular 2 in its native, statically-typed environment. We’ll look at the new change-detection method in detail, how Directives and Components change how you create websites with Angular, the new Angular 2 router, and much more.</p> <p>By the end of the book, you’ll be ready to start building quick and efficient Angular 2 applications that take advantage of all the new features on offer.</p>
Table of Contents (16 chapters)
Switching to Angular 2
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Getting to know Angular 2 components


Model View Controller (MVC) is a micro-architectural pattern initially introduced for the implementation of user interfaces. As AngularJS developers, we use different variations of this pattern on a daily basis, most often Model View ViewModel (MVVM). In MVC, we have the model, which encapsulates the business logic of our application, and the view, which is responsible for rendering the user interface, accepting user input, as well as delegating the user interaction logic to the controller. The view is represented as the composition of components, which is formally known as the composite design pattern.

Let's take a look at the following structural diagram, which shows the composite design pattern:

Fig. 5

Here we have three classes:

  • An abstract class called Component.

  • Two concrete classes called Leaf and Composite. The Leaf class is a simple terminal component in the component tree that we're going to build soon.

The Component class defines an abstract operation...