GoConqr has a new look! Let us know what you think.

Module 7 of 7 · Text

class 7 - Crear un to do list

FREDYS FERNANDEZ

Archivo js

angular.module("ToDoList",["LocalStorageModule"])
.controller("ToDoController", function($scope, localStorageService){
    if (localStorageService.get("angular-todoList")) {
        $scope.todo = localStorageService.get("angular-todoList");
    }else {
        $scope.todo = [];
    }

    $scope.$watchCollection("todo",function(newValue, oldValue){
        localStorageService.set("angular-todoList",$scope.todo);
    })
    
    $scope.AddActividad = function(){
        $scope.todo.push($scope.newActividad);
        $scope.newActividad = {};
    }

    $scope.clearActividad = function(){
        $scope.todo = [];
    }
});

 

Archivo html

<!DOCTYPE html>
<html ng-app="ToDoList">
  <head>
    <meta charset="utf-8">
    <title>Hola controller con Angular JS</title>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.32/angular.min.js"></script>
    <script src="controller.js"></script>
    <script src="angular-local-storage.min.js"></script>
  </head>
  <body ng-controller="ToDoController">
        <ul>
            <li ng-repeat="Actividad in todo">
                {{Actividad.descripcion}} -
                {{Actividad.fecha | date: 'short'}}            
            </li>
        </ul>
        <form ng-submit="AddActividad()">
            <input type="text" ng-model="newActividad.descripcion">
            <br><br>
            <input type="datetime-local" ng-model="newActividad.fecha">
            <br><br>
            <input type="submit" value="Guardar actividad">
            <button ng-click="clearActividad()">Limpiar</button>
        </form>
  </body>
</html>

Instructions

You must submit an attempt for this quiz to progress. You can submit it after the last question.

Go to the chosen module

Feedback

What is it about?

What do you think of the new look?

How do you like it?