我正在使用ng-repeat,我必须以动态的方式放置ng-model。代码如下;
Option Explicit
Private Const WIN32_NULL As Long = 0
Private Const WIN32_FALSE As Long = 0
Private Enum CS_FLAGS
CRYPT_STRING_HEX = &H4&
End Enum
Private Declare Function CryptStringToBinary Lib "Crypt32" _
Alias "CryptStringToBinaryW" ( _
ByVal pszString As Long, _
ByVal cchString As Long, _
ByVal dwFlags As CS_FLAGS, _
ByVal pbBinary As Long, _
ByRef cbBinary As Long, _
ByVal pdwSkip As Long, _
ByRef dwFlagsActual As CS_FLAGS) As Long
Private Sub HexToBytes(ByRef HexData As String, ByRef Bytes() As Byte)
Dim OutLen As Long
Dim dwActualUsed As CS_FLAGS
OutLen = UBound(Bytes) - LBound(Bytes) + 1
If CryptStringToBinary(StrPtr(HexData), _
Len(HexData), _
CRYPT_STRING_HEX, _
VarPtr(Bytes(LBound(Bytes))), _
OutLen, _
WIN32_NULL, _
dwActualUsed) = WIN32_FALSE Then
Err.Raise &H8004A700, _
"HexToBytes", _
"CryptStringToBinary failed, error " & CStr(Err.LastDllError)
End If
End Sub
Private Sub Form_Load()
Const EXAMPLE_ONE As String = "41 42 43 44 45 46 47 48"
Const EXAMPLE_TWO As String = _
"4C6F72656D20697073756D20646F6C6F722073697420616D65742C20636F6E73" _
& "656374657475720D0A61646970697363696E6720656C69742E20557420696E20" _
& "75726E6120677261766964612C0D0A68656E647265726974206D69206E6F6E2C" _
& "20666163696C6973697320616E74652E0D0A0D0A41656E65616E20616320656E" _
& "696D2074656D7075732C206C6163696E69612070757275730D0A717569732C20" _
& "766F6C75747061742076656C69742E2053757370656E64697373652071756973" _
& "0D0A636F6D6D6F646F206E6962682E204E616D206574206C696265726F206575" _
& "206C65637475730D0A73616769747469732072686F6E6375732E2E2E2E2E2E21"
Dim One(1 To 8) As Byte
Dim Two(0 To 255) As Byte
AutoRedraw = True
HexToBytes EXAMPLE_ONE, One
Print UBound(One) - LBound(One) + 1; ":"
Print StrConv(One, vbUnicode)
HexToBytes EXAMPLE_TWO, Two
Print UBound(Two) - LBound(Two) + 1; ":"
Print StrConv(Two, vbUnicode)
End Sub
我的 $ parent.shared.sourceSchema 如下;
<div class="panel panel-default" ng-repeat="(key, value) in $parent.shared.sourceSchema">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapse1">
{{value.sourceName}}
</a>
</h4>
</div>
<div id="collapse1" class="panel-collapse collapse in">
<div class="panel-body">
<div ng-repeat="col in value.columns">
<input ng-model=$parent.value[sourceSrNo] type="radio">{{col.column}}
</div>
</div>
</div>
</div>
但应用的ng模型不起作用。
我尝试了以下不同的方式;
Object {1: Object}
1:Object
columns:Array[7]
sourceName:"S3"
sourceSrNo:1
__proto__:Object
这些都不适合我。
我想为每个外部ng-repeat
保留相同的ng-model值ng-model =“$ parent.value.sourceSrNo”的结果如下;
答案 0 :(得分:0)
尝试替换 $ parent.value [sourceSrNo] 同 value.sourceSrNo