那是我的带对象的数组:
//Controller
$scope.form = [
{
name: 'Lname',
items: [{
label: 'Lastname',
type: 'text',
model: 'lname',
pattern: '/^[a-zA-Z]$/',
required: true
}]
},
{
name: 'Fname',
items: [{
label: 'Firstname',
type: 'text',
model: 'fname',
pattern: '/^[a-zA-Z]$/',
required: true
}]
}];
以下是我的观点形式:
<form class="form-horizontal" name="editForm" novalidate>
<div ng-repeat="elements in form">
<div class="form-group-sm has-feedback" ng-repeat="el in elements.items">
<label class="control-label">{{el.label}}</label>
<input type="{{el.type}}"
class="form-control"
placeholder="{el.label}"
ng-model="selected.[el.model]"
ng-pattern="el.pattern"
ng-required="el.required"
/>
仅正确显示标签。其他变量无法正确处理。有什么问题?
答案 0 :(得分:0)
您需要插入图案和标签,因此请更改:
placeholder="{el.label}"
ng-pattern="el.pattern"
要:
placeholder="{{el.label}}"
ng-pattern="{{el.pattern}}"