O'Reilly logo

HTML5 Data and Services Cookbook by Mite Mitreski, Gorgi Kosev

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Rendering lists and using Angular controllers

Angular allows us to interact with our view through code by letting us set a controller for the view. The controller can modify the view scope (the model) and call other operations, such as background services.

In this recipe, we're going to use a controller to write a simple to-do list.

How to do it...

Let's get started.

  1. Create a file named index.html that will display a list of tasks, the form to add a new task, and the button to hide all the tasks:
    <!doctype html> <html ng-app> <head> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.min.js"></script> <script src="example.js"></script> </head> <body> <div ng-controller="TodoListController"> <ul> <li ng-repeat="task in tasks" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required