这是相对简单的,或者说我是这么想的。
我有一个自定义的角指令-我可以用
<custom-directive ng-model="someAngularScopeObject"></custom-directive>我的问题是,如何将它应用到Kendo Grid列模板中。
我的网格是使用DOM角属性定义的,而kendo网格k-选项是在角范围内指定的。
对于列模板,如何将行的列dataItem绑定到自定义指令ng模型?
基本上,在网格的k选项中:
columns: [
{ field: "name", title: "Name" },
{ field: "description", title: "Description" },
{ field: "managerName", title: "Manager",
template: function (dataItem) {
//what I care about is dataItem.prop1
return ("<custom-directive ng-model='???????????'>
</custom-directive>");
}
}]网格和网格的数据源位于角控制器的范围内
发布于 2017-01-30 20:59:12
对于R模板,您可以这样尝试:
columns: [
{ field: "name", title: "Name" },
{ field: "description", title: "Description" },
{ field: "managerName", title: "Manager",
template: function (dataItem) {
//what I care about is dataItem.prop1
var scope = angular.element("idofelement_with_your_scope").scope();
scope.someAngularScopeObject = dataItem.prop1;
return ("<custom-directive ng-model='someAngularScopeObject'>
</custom-directive>");
}
}]我还没有测试过它,但它应该做好这项工作。其思想是,在template函数中,您有一个值,而在指令中,您需要绑定一个属性/对象。
https://stackoverflow.com/questions/41945082
复制相似问题