Angular Event Binding, To-do List

How to perform Angular Event Binding
import {Component} from '@angular/core'; @Component({
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent{
name: 'Jsrd';
show:boolean;
welcomeMe(username){
this.name=username;
this.show=true;
}}

How to create a To-do List in Angular

import {Component} from '@angular/core'; @Component({
selector: 'app-root',
templateUrl: './app.component.html'
styleUrls:['./app.component.css']
})
export class AppComponent{
todos:any
done:boolean
newToDo: String
neToDoObj:any
error:boolean
TODOS: any[]
constructor(){
this.neToDo='';
this.todos=[];
addMore(newToDo){
if(this.newToDoObj={
newTodo:this.newToDo,
done:false
}
this.todos.push(this.neToDoObj);
this.newToDo='';
}
else
{
this.error=true
}
console.log(this.todos);
}
clearAll(){
this.todos.length=0;
}
}


Leave a Comment

Your email address will not be published. Required fields are marked *