how to get specific item that selected?

后端 未结 1 560
深忆病人
深忆病人 2021-01-14 23:36
  • screenshot attached.

I learning angularJS. And i can\'t find a way to remove the selected item that the \'Remove\' button was click on.

Is th

1条回答
  •  醉话见心
    2021-01-15 00:03

    var app = angular.module("app" , []);
    app.controller("MyCtrl" , function($scope){
      
      $scope.todos = [
        {"text" :"Learn AngularJS","done":false},{"text" :"build an app","done":false}];
      
      $scope.removeTodo = function(index) {
        $scope.todos.splice(index,1);
        
        }
      
      $scope.removeTodo2 = function(todo) {
        var index = getByValue( $scope.todos,todo);
        $scope.todos.splice(index,1);
        
        }
      
      $scope.addTodo = function(todo){
        var toDoObject = {"text":todo,"done":false};
        $scope.todos.push(toDoObject);
        
      };
      
      $scope.done = function(todo){
        angular.forEach($scope.todos,function(index,todo1){
            if(todo == todo1)
               $scope.todos[index].done = !$scope.todos[index].done;
          })
       
        
        }
      
      function getByValue(arr, value) {
    
      for (var i=0, iLen=arr.length; i
    .done{
      text-decoration: line-through;
      }
    
    
    • {{todo.text}}

    0 讨论(0)
提交回复
热议问题