I'm doing a to do list app, I'd like to know how to hide an element after 5 seconds after I've selected the item through my checkbox.
I have the following HTML structure:
<body ng-controller="todoListCtrl">
<div class="container">
<div class="jumbotron">
<h4><img src="img/list.png" id="icon-list"> {{app}} </h4>
<table class="table ">
<tr ng-class="{selecionado: item.selecionado}" ng-repeat="item in tarefas">
<td><input type="checkbox" ng-model="item.selecionado"></td>
<td><input type="text" ng-class="{selecionado: item.selecionado}"class="form-control" id="item" ng-model="item.titulo" ng-blur="item.modoEdicao = false" ng-focus="item.modoEdicao = true" ></td>
</tr>
</table>
</hr>
<form ng-submit="adicionarTarefa(item)">
<input class="form-control" type="text" ng-model="item.titulo" placeholder="Escrever nova tarefa.." ng-keyup="$event.keyCode == 13 && (adicionarTarefa)"/>
</form>
<button class="btn btn-danger btn-block" ng-click="apagarTarefa(tarefas)">Apagar tarefa</button>
</div>
</div>
</body>
I have the following code JavaScript
so far:
//localizando o modulo
angular.module("todoList").controller("todoListCtrl", function($scope) {
$scope.app = "Minhas Tarefas";
$scope.tarefas = [{
titulo: "Fazer o documento do carro",
modoEdicao: false
},
{
titulo: "Solicitar emprestimo bancario",
modoEdicao: false
}
];
//Comportamento do ng click - Cadastro tarefas
$scope.adicionarTarefa = function(item) {
$scope.tarefas.push(angular.copy(item));
};
//Comportamento do ng click - Apagar tarefas
$scope.apagarTarefa = function(tarefas) {
$scope.tarefas = tarefas.filter(function(item) {
if (!item.selecionado) return item;
});
};
});
// function autoFocus (){
// $('#teste').focus();
// };
$(document).ready(function() {
setInterval(function() {
$('#item').fadeOut(1500);
}, 3000);
});