Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
todo-item-list-row.component.ts
@Component({
selector: 'app-todo-item-list-row',
templateUrl: './todo-item-list-row.component.html',
styleUrls: ['./todo-item-list-row.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class TodoItemListRowComponent implements OnInit {
private _todoItem : TODOItem;
public get todoItem() : TODOItem {
return this._todoItem;
}
@Input()
public set todoItem(v : TODOItem) {
this._todoItem = v;
this.cdr.detectChanges();
}
@Input() public readOnlyTODO: boolean;
@Output() public todoDelete = new EventEmitter();
@Output() public todoEdit = new EventEmitter();
@Output() public todoComplete = new EventEmitter<TODOItem>();
constructor(private cdr: ChangeDetectorRef) {}
public ngOnInit() {
this.cdr.detach();
}
public completeClick() {
const newTodo = {
...this.todoItem,
completed: !this.todoItem.completed
};
this.todoComplete.emit(newTodo);
}
public deleteClick() {
this.todoDelete.emit(this.todoItem.id);
}
public editClick() {
this.todoEdit.emit(this.todoItem);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.