我有这种动态形式,或者至少部分是动态的。 我想在屏幕上注销一些表单属性的值来帮助我。 以下类型的工作,但页面上的文字没有更新。
非常感谢任何帮助。
<span>{{property.name}}-Error:roomForm['property'+property.id].$error</span>
还尝试过:
{
"$error" : {
"required" : [{
"$viewValue" : "",
"$modelValue" : "",
"$validators" : {},
"$asyncValidators" : {},
"$parsers" : [null],
"$formatters" : [null, null],
"$viewChangeListeners" : [],
"$untouched" : true,
"$touched" : false,
"$pristine" : true,
"$dirty" : false,
"$valid" : false,
"$invalid" : true,
"$error" : {
"required" : true
},
"$name" : "Name",
"$options" : null
}, {
"$viewValue" : "",
"$modelValue" : "",
"$validators" : {},
"$asyncValidators" : {},
"$parsers" : [null, null, null],
"$formatters" : [null, null],
"$viewChangeListeners" : [],
"$untouched" : true,
"$touched" : false,
"$pristine" : true,
"$dirty" : false,
"$valid" : false,
"$invalid" : true,
"$error" : {
"required" : true
},
"$name" : "Capacity",
"$options" : null
}, {
"$viewValue" : "",
"$modelValue" : "",
"$validators" : {},
"$asyncValidators" : {},
"$parsers" : [null, null, null],
"$formatters" : [null, null],
"$viewChangeListeners" : [],
"$untouched" : true,
"$touched" : false,
"$pristine" : true,
"$dirty" : false,
"$valid" : false,
"$invalid" : true,
"$error" : {
"required" : true
},
"$name" : "property",
"$options" : null
}, {
"$viewValue" : "",
"$modelValue" : "",
"$validators" : {},
"$asyncValidators" : {},
"$parsers" : [null, null, null],
"$formatters" : [null, null],
"$viewChangeListeners" : [],
"$untouched" : true,
"$touched" : false,
"$pristine" : true,
"$dirty" : false,
"$valid" : false,
"$invalid" : true,
"$error" : {
"required" : true
},
"$name" : "property",
"$options" : null
}, {
"$viewValue" : "",
"$modelValue" : "",
"$validators" : {},
"$asyncValidators" : {},
"$parsers" : [null],
"$formatters" : [null, null],
"$viewChangeListeners" : [],
"$untouched" : true,
"$touched" : false,
"$pristine" : true,
"$dirty" : false,
"$valid" : false,
"$invalid" : true,
"$error" : {
"required" : true
},
"$name" : "property",
"$options" : null
}
]
},
"$name" : "roomForm",
"$dirty" : true,
"$pristine" : false,
"$valid" : false,
"$invalid" : true,
"$submitted" : false,
"Name" : {
"$viewValue" : "",
"$modelValue" : "",
"$validators" : {},
"$asyncValidators" : {},
"$parsers" : [null],
"$formatters" : [null, null],
"$viewChangeListeners" : [],
"$untouched" : true,
"$touched" : false,
"$pristine" : true,
"$dirty" : false,
"$valid" : false,
"$invalid" : true,
"$error" : {
"required" : true
},
"$name" : "Name",
"$options" : null
},
"description" : {
"$viewValue" : "",
"$modelValue" : "",
"$validators" : {},
"$asyncValidators" : {},
"$parsers" : [null],
"$formatters" : [null, null],
"$viewChangeListeners" : [],
"$untouched" : true,
"$touched" : false,
"$pristine" : true,
"$dirty" : false,
"$valid" : true,
"$invalid" : false,
"$error" : {},
"$name" : "description",
"$options" : null
},
"Capacity" : {
"$viewValue" : "",
"$modelValue" : "",
"$validators" : {},
"$asyncValidators" : {},
"$parsers" : [null, null, null],
"$formatters" : [null, null],
"$viewChangeListeners" : [],
"$untouched" : true,
"$touched" : false,
"$pristine" : true,
"$dirty" : false,
"$valid" : false,
"$invalid" : true,
"$error" : {
"required" : true
},
"$name" : "Capacity",
"$options" : null
},
"property" : {
"$viewValue" : "",
"$modelValue" : "",
"$validators" : {},
"$asyncValidators" : {},
"$parsers" : [null],
"$formatters" : [null, null],
"$viewChangeListeners" : [],
"$untouched" : true,
"$touched" : false,
"$pristine" : true,
"$dirty" : false,
"$valid" : false,
"$invalid" : true,
"$error" : {
"required" : true
},
"$name" : "property",
"$options" : null
}
}
哪个不起作用
{{roomForm}}的输出
while (reader.Read())
{
var values = new object[reader.FieldCount];
reader.GetValues(values);
yield return values;
}
答案 0 :(得分:1)
请尝试:JSFiddle。您需要为表单字段指定一个名称,以使Angular将属性附加到表单(在$scope
上)。
代码很简单:
<div ng-app="Joy">
<form action="" name="myForm">
<input type="text" ng-model="myInput" name="inputName">
{{ myForm.inputName | json }}
</form>
</div>
答案 1 :(得分:0)
试试这个
https://jsfiddle.net/9y80vL6o/
<div ng-app="Joy">
<form action="" name="roomForm">
<input type="text" ng-model="myInput" name="Capacity" required>
<pre>{{ roomForm['Capacity'] | json }} </pre>
</form>
</div>
我不知道你是如何动态创建输出的