我试图进行动态输入。是否有可能通过索引获得动态ng模型?
据推测,应将上面的条形码ng模型设置为ng-model =" barcode_0"和ng-model =" barcode_1"我已尝试过此代码,但它无效
//controller
console.log($scope['Barcode_' + index])

<!-- HTML -->
<input type="text" ng-model="Barcode_[$index]" class="form-control" placeholder="Stock ID" >
&#13;
答案 0 :(得分:1)
你走在正确的轨道上,你只需要对代码进行一些改动。
Private Sub buttonCreated_itemClick(sender As Object, e As ItemClickEventArgs)
If formOfTarget.ContainsKey(CType(e, ItemClickEventArgs).Item.Name) Then
Try
Dim targetOfButton = formOfTarget.Item(CType(e, ItemClickEventArgs).Item.Name)
Dim formCreated As Type = Type.[GetType]("namespace." + targetOfButton)
Dim showForm As Form = TryCast(Activator.CreateInstance(formCreated), Form)
showForm.MdiParent = Me
showForm.Show()
showForm.BringToFront()
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End If
End Sub
是数组Barcode_[$index]
的元素。您只需在Barcode_
中initialize
此数组,然后就可以在controller
中使用$scope.Barcode_[0]
和$scope.Barcode_[1]
来访问变量。
保持html代码原样,并且这是你的控制器:
controller
您可以在此控制器中访问此类变量:
$scope.Barcode_ = [];//initializing the array