Created
March 31, 2019 16:39
-
-
Save lydemann/5a587edb2e8b4b1959250f96433e460b to your computer and use it in GitHub Desktop.
todo-item-list-row.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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