Поэтому я использовал руководство здесь: https://angular.io/docs/ts/latest/cookbook/dynamic-form.html
Мне нужно добавить дополнительные поля к существующему полю. Я сделал что-то, что работает, но оно неуклюже и сбрасывает форму, когда я нажимаю на него. Код ниже:
В динамической форме.component.ts:
add_textbox()
{
this.questions.push(this.questionService.create_textbox({key: "test", label: "Test"}));
console.log(this.questions);
this.form = this.qcs.toFormGroup(this.questions);
}
В вопросе.service.ts
create_textbox({key, value, label = '', order = 1, type = "text", description = "", help = ""}: {key?: any, value?: any, label?: any, order?: any, type?: any, description?: any, help?: any})
{
return new TextboxQuestion({
key,
label,
value,
order,
description,
type
});
}
Моя кнопка также находится в dynamic-form.component.html
, но я бы хотел, чтобы она была в dynamic-form-question.component.ts
. Это возможно?