Permalink
Browse files

ngRepeat duplicate issue fixed

  • Loading branch information...
=
= committed Feb 21, 2018
1 parent 0d717ac commit 21394bca8d12bae7c218afba79a158ce82afa6f0
Showing with 6 additions and 3 deletions.
  1. +6 −3 ToDo.html
@@ -1,9 +1,11 @@
<!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
@@ -13,13 +15,14 @@
Todo.controller("ToDoCtrl", function($scope){
// Creating an array holder for items
$scope.items = [
{ name: 'Sample Item'}
//{ name: 'Sample Item'}
];
// Function to add items to array... fingers crossed X=
$scope.add = function (item){
$scope.items.push(item);
};
});
@@ -28,11 +31,11 @@

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



0 comments on commit 21394bc

Please sign in to comment.