Last active
December 26, 2015 20:59
-
-
Save ozaydinb/7213361 to your computer and use it in GitHub Desktop.
Angular.js Todo Sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html ng-app> | |
<head> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.min.js"></script> | |
<script src="todoController.js"></script> | |
<script src="todo.js"></script> | |
<style type="text/css"> | |
.todoCompleted { | |
text-decoration: line-through; | |
} | |
</style> | |
</head> | |
<body> | |
<div ng-controller="todoController"> | |
<table> | |
<tr> | |
<td colspan="2">Ara:<input type="text" ng-model="searchText" /></td> | |
</tr> | |
<tr> | |
<td><input type="text" ng-model="todoName"> </input></td> | |
<td><button ng-click="addTodo(todoName)">Ekle</button></td> | |
</tr> | |
</table> | |
<ul> | |
<li ng-repeat="todo in todoList | filter:searchText"> | |
<input type="checkbox" ng-model="todo.isCompleted"> | |
<span ng-class="{todoCompleted:todo.isCompleted}">{{todo.name}}</span> | |
<button ng-click="deleteTodo($index)">Sil</button> | |
</li> | |
</ul> | |
</div> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created by Baris.Ozaydin on 29.10.2013. | |
*/ | |
var todo= function(name) { | |
return { | |
name:name, | |
isCompleted:false | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created by Baris.Ozaydin on 29.10.2013. | |
*/ | |
'use strict'; | |
function todoController($scope) { | |
$scope.todoList =[]; | |
$scope.deleteTodo = function(index) { | |
$scope.todoList.splice(index,1); | |
}; | |
$scope.addTodo = function() { | |
var id = $scope.todoList.length; | |
$scope.todoList.push(new todo($scope.todoName,id)); | |
$scope.todoName=''; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment