framadate-responsive/src/app/pages/answers/answers.component.ts

34 lines
908 B
TypeScript
Raw Normal View History

2019-08-10 17:41:01 +02:00
import {Component, OnInit} from '@angular/core';
import {BaseComponent} from '../base-page/base.component';
import {ConfigService} from '../../config.service';
@Component({
selector: 'framadate-answers',
templateUrl: './answers.component.html',
styleUrls: ['./answers.component.scss']
})
export class AnswersComponent extends BaseComponent implements OnInit {
2019-08-10 18:14:00 +02:00
private answerList=[];
2019-08-10 17:41:01 +02:00
constructor(config: ConfigService) {
super(config);
2019-08-10 18:14:00 +02:00
this.answerList = this.config.answers;
2019-08-10 17:41:01 +02:00
}
// todo, manage validation of each page in a common way
ngOnInit() {
}
2019-08-10 18:14:00 +02:00
trackFunction(index: number, item: any): number { return item.id; }
2019-08-10 17:41:01 +02:00
// add a new answer on the press of ENTER in an input
addWhenEnterKey(event) {
2019-08-10 18:14:00 +02:00
console.log('event', event);
2019-08-10 17:41:01 +02:00
if (event.keyCode === 13) {
this.config.addAnswer();
}
2019-08-10 18:14:00 +02:00
return;
2019-08-10 17:41:01 +02:00
}
}