TODO with AngularJS (ENTER to submit and delete item)



examples/angular/todo2.html
<script src="angular.min.js"></script>
<script src="todo2.js"></script>
<div ng-app="todoApp" ng-controller="todoController">
    <form ng-submit="add()">
    <input ng-model="title"><button>Add</button>
    </form>
    <ul>
        <li ng-repeat="t in tasks track by $index">{{ t }}
             <button ng-click="delete()">x</button></li>
    </ul>
</div>

examples/angular/todo2.js
angular.module('todoApp', [])
    .controller('todoController', ['$scope', function($scope) {
        $scope.tasks = [];
        $scope.add = function() {
            $scope.tasks.push($scope.title);
        }
        $scope.delete = function() {
            $scope.tasks.splice(this.$index, 1);
        }
    }]);