我想从。
创建自定义指令数据数据从= “ID-雇员”
属性“data-from”表示此字段集的输入必须包含以“id-employee”开头的字段集的值
用户应该能够从员工列表中选择一位领导者。
任何想法? 在此先感谢!!
<form>
<fieldset id="id-employee[0]">
<input type="text" name="name-employee[0]"/>
<input type="text" name="lastname-employee[0]"/>
</fieldset>
<fieldset id="id-employee[1]">
<input type="text" name="name-employee[1]"/>
<input type="text" name="lastname-employee[1]"/>
</fieldset> <fieldset id="id-employee[2]">
<input type="text" name="name-employee[2]"/>
<input type="text" name="lastname-employee[2]"/>
</fieldset>
<fieldset id="id-leader" data-from="id-eployee">
<select id="select-employee">
<option>Select a Team leader</option>
<option id="select-employee-0" value="0">name lastname of the employee 0</option>
<option id="select-employee-0" value="1">name lastname of the employee 1</option>
<option id="select-employee-0" value="2">name lastname of the employee 2</option>
</select>
<input type="text" name="name-leader"/>
<input type="text" name="lastname-leader"/>
</fieldset>
</form>
答案 0 :(得分:0)
您可以使用数据绑定来实现这一点 -
<form ng-init="employees=[]">
<fieldset id="id-employee[0]">
<input type="text" model="employees[0].name" name="name-employee[0]"/>
<input type="text" model="employees[0].lastname" name="lastname-employee[0]"/>
</fieldset>
然后在select
中绑定它<select ng-model="leader" ng-options="employee.name as employee.name for employee in employees"></select>