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.
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" ng-show="task.shown"> <input type="checkbox" ng-model="task.complete"> {{task.text}} </li> </ul> <form ng-submit...