src/app/todo-details/todo-details.component.ts
| selector | app-todo-details |
| styleUrls | ./todo-details.component.css |
| templateUrl | ./todo-details.component.html |
Properties |
Methods |
constructor(TodosService: TodosService, _activateRoute: ActivatedRoute)
|
|||||||||
|
Parameters :
|
| deleteTodo | ||||||
deleteTodo(id: number)
|
||||||
|
Parameters :
Returns :
void
|
| loveTodo | ||||||
loveTodo(id: number)
|
||||||
|
Parameters :
Returns :
void
|
| ngOnInit |
ngOnInit()
|
|
Returns :
void
|
| toggleCompleted | ||||||
toggleCompleted(todo: Todo)
|
||||||
|
Parameters :
Returns :
void
|
| todo |
Type : Todo | undefined
|
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { TodosService } from '../todos.service'
import { Todo } from '../Todo';
@Component({
selector: 'app-todo-details',
templateUrl: './todo-details.component.html',
styleUrls: ['./todo-details.component.css']
})
export class TodoDetailsComponent implements OnInit{
todo!: Todo | undefined;
constructor(private TodosService: TodosService, private _activateRoute: ActivatedRoute) { }
ngOnInit(): void {
const id: number = this._activateRoute.snapshot.params['id'];
this.todo = this.TodosService.getTodo(id);
}
deleteTodo(id: number):void {
this.TodosService.deleteTodo(id);
}
loveTodo(id: number):void {
console.log(id);
this.TodosService.loveTodo(id);
}
toggleCompleted(todo: Todo):void {
// Call the service method to update the original todos array
this.TodosService.toggleCompleted(todo);
}
}
<div class="wrapper">
<ul class="task-box">
<app-todo class="task" *ngIf="todo" [id]="todo.id" [todo]="todo.todo" [favorite]="todo.favorite"
[completed]="todo.completed" (toggleEvent)="toggleCompleted($event)" (deleteEvent)="deleteTodo($event)"
(loveEvent)="loveTodo($event)"></app-todo>
</ul>
</div>
./todo-details.component.css
@import "~bootstrap-icons/font/bootstrap-icons.css";
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: "Poppins", sans-serif;
}
::selection {
color: #fff;
background: #f12711;
}
.wrapper {
max-width: 50%;
background: #fff;
margin: 20px auto;
border-radius: 7px;
padding: 28px 0 30px;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}
.task-input {
position: relative;
height: 52px;
padding: 0 25px;
}
.task-input ion-icon {
position: absolute;
top: 50%;
color: #999;
font-size: 25px;
transform: translate(17px, -50%);
}
.task-input input {
height: 100%;
width: 100%;
outline: none;
font-size: 18px;
border-radius: 5px;
padding: 0 20px 0 53px;
border: 1px solid #999;
}
.task-input input:focus,
.task-input input.active {
padding-left: 52px;
border: 2px solid #f12711;
}
.task-input input::placeholder {
color: #bfbfbf;
}
.controls,
li {
display: flex;
align-items: center;
justify-content: space-between;
}
.controls {
padding: 18px 25px;
border-bottom: 1px solid #ccc;
}
.filters span {
margin: 0 8px;
font-size: 17px;
color: #444444;
cursor: pointer;
}
.filters span:first-child {
margin-left: 0;
}
.filters span.active {
color: #f12711;
}
.filters span i {
margin-right: 3px;
}
.clear-btn {
border: none;
opacity: 0.6;
outline: none;
color: #fff;
cursor: pointer;
font-size: 13px;
padding: 7px 13px;
border-radius: 4px;
letter-spacing: 0.3px;
transition: transform 0.25s ease;
background: linear-gradient(135deg, #f5af19 0%, #f12711 100%);
}
.clear-btn.active {
opacity: 0.9;
pointer-events: auto;
}
.clear-btn:active {
transform: scale(0.93);
}
.task-box {
margin-top: 20px;
margin-right: 5px;
padding: 0 20px 10px 25px;
}
.task-box.overflow {
overflow-y: auto;
max-height: 300px;
}
.task-box::-webkit-scrollbar {
width: 5px;
}
.task-box::-webkit-scrollbar-track {
background: #f12711;
border-radius: 25px;
}
.task-box::-webkit-scrollbar-thumb {
background: #e6e6e6;
border-radius: 25px;
}
.user-details {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 10px;
border-radius: 5px;
border: 1px solid #e6e6e6;
background-color: #eee;
-webkit-box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2);
-moz-box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2);
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2);
width: 50%;
margin: 20px auto;
font-size: 100px;
font-family: Futura;
background-color: #666666;
-webkit-background-clip: text;
-moz-background-clip: text;
background-clip: text;
color: transparent;
text-shadow: rgba(245, 245, 245, 0.5) 3px 5px 1px;
}
@media (max-width: 400px) {
body {
padding: 0 10px;
}
.wrapper {
padding: 20px 0;
}
.filters span {
margin: 0 5px;
}
.task-input {
padding: 0 20px;
}
.controls {
padding: 18px 20px;
}
.task-box {
margin-top: 20px;
margin-right: 5px;
padding: 0 15px 10px 20px;
}
.task label input {
margin-top: 4px;
}
}