Permalink
Browse files

fixed input value being bound to all list items

  • Loading branch information...
=
= committed Feb 21, 2018
1 parent 21394bc commit 3a95d87932657f3e0f08d768f306f6ee02cb8186
Showing with 46 additions and 0 deletions.
  1. +46 −0 index.html
@@ -0,0 +1,46 @@
<!DOCTYPE html>
<html lang="en" ng-app="Todo">
<meta charset="utf-8"/>
<head>
<title>To Do</title>
<script src="angular.js"></script>
<link rel="stylesheet" type="text/css" href="todo.css">
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css">

<script>
// Todo module
var Todo = angular.module("Todo", []);
// Create and register controller to module
Todo.controller("ToDoCtrl", function($scope){
// Creating an array holder for items
$scope.items = [
//{ name: 'Sample Item'}
];
// Function to add items to array... fingers crossed X=
$scope.add = function (){
$scope.items.push($scope.new);
$scope.new = '';
};
});
</script>
</head>

<body ng-controller="ToDoCtrl">
<h1>To Do</h1>
<ul ng-repeat="item in items track by $index">
<li>{{ item }}</li>
</ul>
<input type="text" ng-model="new"/>
<button type="submit" ng-click="add()">Add</button>



</body>

</html>

0 comments on commit 3a95d87

Please sign in to comment.