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.
Let's get started.
index.htmlthat 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" ...