案例:AngularJS案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<!DOCTYPE html>
2
<html>
3
<script src= "/js/angular.js1.4.6/angular.min.js"></script>
4
<body ng-app="myApp" ng-controller="todoCtrl">
5
6
<h2>我的备忘录</h2>
7
8
<form ng-submit="todoAdd()">
9
    <input type="text" ng-model="todoInput" size="50" placeholder="新增">
10
    <input type="submit" value="新增">
11
</form>
12
13
<br>
14
15
<div ng-repeat="x in todoList">
16
    <input type="checkbox" ng-model="x.done"> <span ng-bind="x.todoText"></span>
17
</div>
18
19
<p><button ng-click="remove()">删除记录</button></p>
20
21
<script>
22
var app = angular.module('myApp', []); 
23
app.controller('todoCtrl', function($scope) {
24
    $scope.todoList = [{todoText:'Clean House', done:false}];
25
26
    $scope.todoAdd = function() {
27
        $scope.todoList.push({todoText:$scope.todoInput, done:false});
28
        $scope.todoInput = "";
29
    };
30
31
    $scope.remove = function() {
32
        var oldList = $scope.todoList;
33
        $scope.todoList = [];
34
        angular.forEach(oldList, function(x) {
35
            if (!x.done) $scope.todoList.push(x);
36
        });
37
    };
38
});
39
</script>
40
41
</body>
42
</html>