4
Kendo k-ng-model
是否支持双向绑定,如果不是,模拟它的最佳方法是什么?如何更新k-ng模型(又名与ng模型的双向绑定)
上下文的位:
在有角的,当一个更新NG-模型完成后,所有感兴趣的各方被更新(例如刷新视图)。在kendo中,当使用k-ng-model时,我无法找到相同的方法,我希望直接从controller/directive中设置值。
下面是一个例子:Coding Dojo
而且,只是在情况下,代码,以及:
<input kendo-auto-complete
k-ng-model="vm.kendoSelection"
ng-model="vm.angularSelection"
k-data-source="vm.countryNames"
k-data-value-field="'name'"
k-data-text-field="'name'" />
样品控制器:
angular.module("MyApp", [ "kendo.directives" ])
.controller("Controller", function(){
// just some data source
this.countryNames = [
{ name: "Albania" },
{ name: "Andorra" }
];
// how to set the k-ng-model here, so that it is also propagated properly (like on
// the view, and that other events like k-on-change work)?
this.kendoSelection = { name: "Albania" };
});
编辑:
即使从翁Dirza答案后,第k电平变化不点火(altough它是在良好的方向中的溶液)
翁Dirza
问题是,k-on-change仍然没有开火,但是这是一个好的方向。 –
在这个[dojo](http://dojo.telerik.com/EwALa)k-on-change完美工作..你有什么问题?也许在不同的背景下提出另一个问题 –
从vm.kendoSelection“后面的代码”设置时,k-on-change会被激发吗?http://dojo.telerik.com/@DenisB/AmaLI/4 –