【发布时间】:2021-11-05 21:27:19
【问题描述】:
这是我当前的表单组
ngOnInit(){
this.admQuizForm = this.fb.group({
name:'',
desc:'',
type:'',
date: new Date(),
questions: [
.....what do i do here
]
});
}
这是我的数据库条目
{"_id":{"$oid":"611b2ba2f29......."},
"name":"quiz1",
"desc":"quiz1",
"type":"history",
"date":"",
"questions":[
{"options":["1","2","3","4"],"question":"whats?","answer":"4"},
{"options":["2","3","4","1"],"question":"whats?","answer":"4"},
{"options":["123","asd","fsa","test"],"question":"whats?","answer":"test"},
{"options":["asd","ads","dsa","aadd"],"question":"whats?","answer":"aadd"}
]}
我正在尝试创建一个表单组以通过我的网站添加新的测验,该网站使用 angular 和 typescript,但我不确定数组如何在表单组中工作。我手动将数据添加到数据库中。
【问题讨论】:
-
你看过
FormArray,你可以使用响应式表单吗? angular.io/guide/reactive-forms#creating-dynamic-forms
标签: html node.js angular typescript