<body ng-app="taskApp">
<h2>A Random List of Tasks</h2>
<div ng-controller="taskCtrl">
<form ng-submit="addtask()">
<input type="text" ng-model="task.title">
<button type="submit">Add Task</button>
<br>
</form>
<ul>
<li class="task-item" ng-repeat="task in tasks">
<span class="done" ng-click="removeItem($index)">X</span>
<span>{{task.title}}</span>
</li>
</ul>
</div>
</body>
body {
font-family: 'Lato';
margin: 10px auto;
max-width: 800px;
}
ul {
padding: 0;
margin-top: 40px;
margin-left: 10px;
font-size: 1.1em;
position: relative;
}
form {
margin-left: 10px;
}
ul li {
list-style: none;
margin: 15px auto;
position: relative;
}
h1 {
margin: 10px;
text-align: center;
}
h2 {
margin: 10px;
}
p {
margin-left: 10px;
}
form {
margin-top: 50px;
}
input {
border: none;
border-bottom: 1px solid orange;
padding: 4px 10px;
outline: none;
}
button {
border: none;
background: cornflowerblue;
color: white;
padding: 5px 12px;
margin-left: 20px;
border-radius: 4px;
}
.done {
font-size: 0.7em;
font-weight: bold;
background: black;
color: white;
padding: 1px 5px;
position: relative;
top: -3px;
border-radius: 2px;
margin-right: 10px;
cursor: pointer;
}
.done:hover {
background: rgb(200, 0, 0);
}
@keyframes added {
from {
opacity: 0;
top: -500px;
}
to {
opacity: 1;
top: 0px;
}
}
@keyframes deleted {
from {
top: 0;
opacity: 1;
}
to {
top: 200px;
opacity: 0;
}
}
.task-item.ng-enter {
animation: 0.25s linear added;
}
.task-item.ng-leave {
animation: 0.25s linear deleted;
}
/*.task-item.ng-enter,
.task-item.ng-leave {
transition:all linear 0.25s;
}
.task-item.ng-leave {
top: 0;
opacity: 1;
}
.task-item.ng-leave.ng-leave-active {
top: 200px;
opacity: 0;
}
.task-item.ng-enter{
opacity:0;
top: -500px;
}
.task-item.ng-enter.ng-enter-active {
opacity:1;
top: 0px;
}*/
var app = angular.module('taskApp', ['ngAnimate']);
app.controller('taskCtrl', function($scope) {
$scope.tasks = [
{ title: 'Go to the Zoo'},
{ title: 'Take a Nap'},
{ title: 'Start Learning AngularJS'},
{ title: 'Meet Susan at the Gym'}
];
$scope.addtask = function() {
$scope.tasks.push($scope.task);
$scope.task = {};
};
$scope.removeItem = function(index) {
$scope.tasks.splice(index, 1);
};
});