Angular-在编辑时填充表单数组输入

时间:2018-08-01 05:01:16

标签: angular ngrx ngxs

我有一个数量字段和一个“添加”按钮。单击按钮后,将添加数量的新字段以及“删除”按钮以将其删除。 我已经使用了Form数组

我的代码如下

filter

我还具有编辑功能,我想在其中预填充数量字段及其之前保存的用于编辑的数量

我的代码如下:

Sub CreateClassesNEWWB()

'allows hyperlinks in other workbooks to be driven off sub in this workbook
Dim ws As Worksheet
Dim HyperlinksClass As cHyperlinks

'Create A New Instance Of The Collection
Set objCollection = New Collection

For Each wb In Workbooks             '<loop workbooks
    For Each ws In wb.Worksheets     '<loop worksheets
        objCollection.Add LinkHandler(ws)
    Next ws
Next wb

End Sub

'I like "factory" functions partly to be sure
'  I'm creating all objects as independent instances...
Function LinkHandler(ws As Worksheet) As cHyperlinks
    Dim rv As New cHyperlinks
    Set rv.obj = ws
    Set LinkHandler = rv
End Function

但是该值未在输入字段中填充。谁能指导

2 个答案:

答案 0 :(得分:1)

您的状态配置错误:

export const Users = [
  {
      "id": "1",
      "name": "aaa",
      "technology": "1" //<------ Use id instead of names
  },
  {
      "id": "2",
      "name": "bbb",
      "technology": "1,2" //<------ Use id instead of names
  },
  {
      "id": "3",
      "name": "ccc",
      "technology": "1,3" //<------ Use id instead of names
  }
]

Working Demo

答案 1 :(得分:0)

似乎您要将数量字段与ri.quantity绑定在一起,因此必须在编辑函数中传递此对象,并更改组件ts文件中同一对象(即ri)中的值,例如,

edit(ri){
    ri.quantity=SOME_NEW_VALUE_HERE;
}

已更新,用于在选项中添加所选属性,

<option ... [selected]="ingredient.id==ri.ingredient">
   {{ingredient.name}}
</option>