The ToDo app is used to help us to remember some important task. We just add the task and when accomplished, delete them. This to-do list uses various Bootstrap classes that make our web application not only attractive but also responsive.
Approach:
- Create a new angular app using following command:
ng new my-todo-list
- Move inside the app by cd and run. After that open local host and check if the app is working.
cd my-todo-list ng serve
- Install bootstrap using the following command:
npm install bootstrap
Edit style.css file in the project
@import 'bootstrap/dist/css/bootstrap.css';chevron_rightfilter_none - Open src/app folder and start editing app.component.html
<!--Division for GeeksForGeeks heading--><divclass="container-fluid"><divclass="row bg-success justify-content-centeralign-items-center"style="height:80px"><divclass="col-3"></div><divclass="col-6 text-light h2">GeeksForGeeks</div></div><!--Division for taking input from user --><divclass="row mt-1"style="height:80px;"><divclass="col-3 d-none col-md-3 d-md-block"></div><divclass="col-12 col-md-6 bg-success d-flexjustify-content-center align-items-centertext-light h3"><input[(ngModel)]="newTask"type="text"value=""class="col-7 form-control"style="width:300px;"><divclass="col-1"></div><button(click)="addToList()"class="btn btn-light text-success">ADD TASK</button></div><divclass="col-3 d-none col-md-3 d-md-block"></div></div><!--Tasks added repeated divisions--><div*ngFor="let x of items; let index = index;"class="row mt-1"style="height:100px;"><divclass="col-3 d-none col-md-3 d-md-block"></div><divclass="col-12 col-md-6 bg-success d-flexjustify-content-center align-items-centertext-light h3"><divclass="col-9 text-light h3">{{x}}</div><input(click)="deleteTask(index)"type="button"value="Delete"class="col-2 btn btn-danger"></div><divclass="col-3 d-none col-md-3 d-md-block"></div></div></div>chevron_rightfilter_none - Open app.component.ts file and write functions for adding and deleting tasks.
import { Component } from'@angular/core';@Component({selector:'app-root',templateUrl:'./app.component.html',styleUrls: ['./app.component.css']})export class AppComponent {/* An empty array that is responsibleto add a division */public items = [];/* A two-way binding performed whichpushes text on division */public newTask;/* When input is empty, it willnot create a new division */public addToList() {if(this.newTask =='') {}else{this.items.push(this.newTask);this.newTask ='';}}/* This function takes to input thetask, that has to be deleted*/public deleteTask(index) {this.items.splice(index, 1);}}chevron_rightfilter_none - For working with forms that is taking input we have to import FormsModule in app.module.ts file.
import { FormsModule } from '@angular/forms'
Output:


Recommended Posts:
- How to create a To-Do list using Drag and Drop in Angular 7 ?
- How to Create ToDo App using ReactJS ?
- How to Create ToDo App using HTML, CSS, JS and Bootstrap ?
- How to create button dynamically with click event in Angular ?
- Adding Angular Material Component to Angular Application
- Angular 7 | Angular Data Services using Observable
- Angular CLI | Angular Project Setup
- Routing in Angular JS using Angular UI Router
- How to create To-Do List using jQuery?
- Create an unordered list without any bullets using CSS
- How to create an ordered list using HTML5 ?
- How to create an unordered list in HTML ?
- Difference between Angular 4 and Angular 5
- How to create comma separated list from an array in PHP ?
- How to Create a Dropdown List with Array Values using JavaScript ?
- Create a comma separated list from an array in JavaScript
- How to create a group of related options in a drop-down list using HTML ?
- How to use jQuery in Angular ?
- Angular 7 | Architecture
- Angular 7 | Directives
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

