Simple To Do List App Using AngularJs
Submitted by razormist on Saturday, March 4, 2017 - 18:14.
In this tutorial we will create a Simple To Do List App Using AngularJs. AngularJS is a structural framework for dynamic web application. It is a structural framework for dynamic web application for a better programming tools.This simple application can help organize your overload works by listing it to priority to least. Let's now do the coding...
Creating The Mark Up
To create the form, Just copy/paste the code below and name it 'index.html'.
Adding Some CSS Style For The Lists
Just copy the code below then paste it inside the head tag.
Creating The AngularJs Directives
To make the angularjs works, copy/paste the code below then name it 'app.js' then save it inside the js folder.
The code above will generate the list to the html form. The $scope.addList function will add some new list when the button is clicked. The $scope.clearList function will delete all the checked checkbox when the button is clicked.
There you have it we just created a simple to do list app using angularjs. I hope that this tutorial help you to what you are looking for. For more updates and tutorials just kindly visit this site, and don't forget to like our page @ Facebook: https://www.facebook.com/SourceCodester/. Enjoy Coding!!
- <!DOCTYPE html>
- <html lang = "en" ng-app = "myModule">
- <head>
- <link rel = "stylesheet" type = "text/css" href = "css/bootstrap.css"/>
- <meta charset = "UTF-8" name = "viewport" content = "width=device-width, initial-scale=1"/>
- </head>
- <body>
- <nav class = "navbar navbar-default">
- <div class = "container-fluid">
- </div>
- </nav>
- <div class = "row">
- <div class = "col-md-6 well">
- <hr style = "border-top:1px dotted #000;"/>
- <div ng-controller = "myController">
- <form name = "listfrm" ng-submit = "addList()">
- <div class = "form-inline">
- <input class = "form-control" type = "text" name = "newlist" placeholder = "Enter list here..." ng-model = "newlist" required = "required" />
- </div>
- </form>
- <br />
- <ul>
- <li ng-repeat = "list in lists">
- <input type = "checkbox" ng-model = "list.done" />
- </li>
- </ul>
- </div>
- </div>
- </div>
- </body>
- </html>
- <style>
- .done{
- text-decoration: line-through;
- color:#ccc;
- }
- ul{
- list-style-type:none;
- }
- ul li{
- font-size:18px;
- color:#5cb85c;
- }
- </style>
- angular.module('myModule', [])
- .controller('myController', ['$scope', function($scope){
- $scope.lists =[
- {name: 'Creating A Database', done: false},
- {name: 'Creating A Database Connection', done: false},
- {name: 'Creating Webpage Layout', done: false},
- {name: 'Adding Some Php Script', done: false},
- {name: 'Adding Javascript Function', done: false},
- {name: 'Need Testing', done: false},
- ];
- $scope.addList = function(){
- $scope.lists.push({name: $scope.newlist, done: false})
- $scope.newlist = "";
- }
- $scope.clearList = function(){
- $scope.lists = $scope.lists.filter(function(item){
- return !item.done;
- });
- }
- }])
Add new comment
- 105 views