Build Lightweight Controllers by Binding to Models in Angular

InstructorLukas Ruebbelke

Share this video with your friends

Send Tweet

In Angular, our controllers should be small and focused on the view that it is controlling. We accomplish this by moving as much logic and state as we can into models. Angular 2 introduced observables and async pipes which make it easy to manage state and communicate that directly to our templates.

We can start to point our Angular 1 applications in that direction by binding to our models directly from within our controllers. In this lesson, we will see a simple example of this technique and a slightly more advanced case where we lose the lexical reference to the this keyword.

Thom
~ 8 years ago

Great course ! I want to use this approach to re-factor an existing NG1 app. What other references are good to use for making an angular 1 app angular 2 ish ?

Lukas Ruebbelkeinstructor
~ 8 years ago

Hey Thom, You are in luck! I have actually created an Egghead course and companion guide on this very topic. See https://www.angular2patterns.com/ and https://egghead.io/courses/using-angular-2-patterns-in-angular-1-x-apps. Thanks!