AngularJS绑定-选择指令
AngularJS bind select directive
我在这里有下拉指令链接
需要一些关于如何绑定我的编辑和保存表单的帮助。
查看/编辑:如何在关键字指令中分配我的supplier.statusID?
<tr ng-repeat="supplier in suppliers">
<td>{{supplier.Id}}</td>
<td>{{supplier.Name}}</td>
<td>
<keywords title="Choose Status" label="" array="myKeyword" opt-value="Id" opt-description="Description"></keywords>
<br />
</td>
</tr>
对于添加新记录:如何将关键字指令的ID保存到我的供应商。statusID
<div>Name: <input type="text" />
<br />
Status: <keywords title="Choose Status" label="" array="myKeyword" opt-value="Id" opt-description="Description"></keywords><br><button>Save</button>
</div>
您只需要在指令的作用域中创建一个名为supplierId
的新属性,并将供应商的ID分配给您声明指令的属性
app.directive('keywords', function(){
return {
restrict: 'E',
scope: {
array: '=',
supplierId : '='
},
template: '<label>{{label}}</label>' +
'<select ng-model="supplierId" ng-options="a[optValue] as a[optDescription] for a in array">'...
在标记中
<td><keywords title="Choose Status" label="" array="myKeyword" opt-value="Id"
supplier-id="supplier.Id" opt-description="Description"></keywords>
<br />
</td>
我用叉子叉了你的小提琴,让它工作
http://jsfiddle.net/XmbHY/
我希望这能有所帮助。
相关文章:
- Angular Datetimepicker:指令'的模板;uib时间选择器'必须只有一个根元素
- AngularJS自定义日期选择器指令
- 指令中选择输入的双向绑定不起作用
- 使用 AngularJS 指令从选择中删除重复项
- 选择2 和 Vue 指令
- 角度指令:当选择更改时,ng 模型未正确更新
- 如何正确选择指令中的元素
- 正在将日期范围选择器转换为角度指令
- 在更改时选择,插入类似函数的参数或指令之间的差异
- 如何根据从下拉列表中选择的选项注入指令模板
- ng-change在我的指令中不适用于选择
- 角度数据-bs-日期选择器指令 + 日期更改
- 角度动态更改从指令中选择的选项
- AngularJS指令,jQuery类选择器不起作用
- 如何从指令链接内部为选择框设置选定值
- ng-repeat指令中的角度选择:如何访问子范围
- 我可以使用 ng 选项创建指令(不使用选择标签)吗?
- 如何从指令的链接函数的“element”参数中选择具有特定ID的元素,使用jQuery而不是angular的jqLite
- AngularJS:选择指令验证
- Angular指令-选择下拉数组或对象模型