how to edit an array in angular

0

Hello, I'm new to js and angular and I'm trying to edit an array where I keep tasks to be developed. I have the following functions to add and delete the elements, but I can not think of a way to edit my tasks after being registered.

I have the following code so far:

Html                        {{app}}       

    <tr ng-class="{selecionado: item.selecionado}" ng-repeat="item in tarefas">
      <td><input type="checkbox" ng-model="item.selecionado"></td>
      <td >{{item.titulo}}</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)"/>

      Delete task   

//Meu array

$scope.tarefas = [
    {
        titulo: "Fazer o documento do carro",
        descricao: "Ano 2015, 2016 e 2017",
        hora: "28/11/2017"
    },
    {
        titulo: "Solicitar emprestimo bancario",
        descricao: "Ano 2015, 2016 e 2017",
        hora: "28/11/2017"
    }
];

//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;
        });
      };

});
    
asked by anonymous 10.08.2017 / 18:00

0 answers