angular
angular
angular
robustes. Voici un exemple pour démarrer avec Angular et créer une application
simple de gestion des tâches (To-Do List).
---
---
---
@Component({
selector: 'app-todo',
templateUrl: './todo.component.html',
styleUrls: ['./todo.component.css']
})
export class TodoComponent {
tasks: { text: string, completed: boolean }[] = [];
newTask: string = '';
addTask() {
if (this.newTask.trim()) {
this.tasks.push({ text: this.newTask, completed: false });
this.newTask = '';
}
}
toggleTask(index: number) {
this.tasks[index].completed = !this.tasks[index].completed;
}
deleteTask(index: number) {
this.tasks.splice(index, 1);
}
}
```
---
---
input {
padding: 10px;
margin-right: 10px;
font-size: 16px;
}
button {
padding: 10px;
font-size: 16px;
cursor: pointer;
}
ul {
list-style: none;
padding: 0;
}
li {
margin: 10px 0;
display: flex;
justify-content: space-between;
align-items: center;
}
li span {
cursor: pointer;
}
li.completed span {
text-decoration: line-through;
color: gray;
}
li button {
background-color: red;
color: white;
border: none;
padding: 5px 10px;
cursor: pointer;
border-radius: 4px;
}
li button:hover {
background-color: darkred;
}
```
---
---
@NgModule({
declarations: [
AppComponent,
TodoComponent
],
imports: [
BrowserModule,
FormsModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
```
---
---