Skip to content

Instantly share code, notes, and snippets.

@artberri
Created May 28, 2019 18:01
Show Gist options
  • Save artberri/4cd844af1389e24948c3763136ce8542 to your computer and use it in GitHub Desktop.
Save artberri/4cd844af1389e24948c3763136ce8542 to your computer and use it in GitHub Desktop.
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