Book Image

DART Cookbook

By : Ivo Balbaert
Book Image

DART Cookbook

By: Ivo Balbaert

Overview of this book

Table of Contents (18 chapters)
Dart Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using a controller


The web page is our view in the MVC pattern. The controller object is responsible for showing data from the model (binding them to DOM elements in the view) and in response to events, possibly changing model data and displaying these changes in the view. All public fields of the controller can be shown, and all public methods can be invoked from within the view. Data binding is done through the same syntax as in Polymer using double curly braces {{ … }}. A controller should contain only the business logic needed for a single app or view; it should not manipulate the DOM.

In this recipe, we'll show you how to work with an Angular controller step by step. You can follow along with the code in the project angular_controller.

How to do it...

Our app will show job type data in a list, and when a job is selected, its details are shown, as shown in the following screenshot:

The controller in action

Its working is explained as follows:

  • The Job class, which is the model, is defined in...