Created
May 28, 2019 18:01
-
-
Save artberri/4cd844af1389e24948c3763136ce8542 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import { Component, Input, HostBinding, OnInit } from '@angular/core'; | |
import { Todo, TodoMixin, ITodoView, TodoPresenter, Injector } from '../../../../../app/src'; | |
import { BaseView } from 'src/app/base.view'; | |
@Component({ | |
selector: '[app-todo]', | |
templateUrl: 'todo.template.html', | |
styles: [] | |
}) | |
export class TodoComponent extends TodoMixin(BaseView) implements ITodoView, OnInit { | |
@Input() | |
public todo: Todo; | |
@HostBinding('class.completed') | |
public isCompleted: boolean = false; | |
@HostBinding('class.editing') | |
public isEditing: boolean = false; | |
public todoTitleInput: string; | |
public readonly presenter: TodoPresenter = Injector.resolve(TodoPresenter); | |
public ngOnInit(): void { | |
this.presenter.attach(this); | |
this.todoTitleInput = this.todo.title | |
} | |
public setEditMode(): void { | |
this.isEditing = true; | |
} | |
public setViewMode(): void { | |
this.isEditing = false; | |
} | |
public completeTodo(): void { | |
this.isCompleted = true; | |
} | |
public activateTodo(): void { | |
this.isCompleted = false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment