0
我正在使用Kendo UI和Angular和Typescript。我知道劍道UI和Angular是一個痛苦,但我必須這樣做...使用Kendo UI排序數組和排序
該視圖很好,但是當我想訪問數組中變化事件和重新排序數組變量doesn不存在。看來這是另一個範圍。所以在這個演示中,彈出警報:
// Change Event
changed(e: kendo.ui.SortableEndEvent) {
console.log(e);
console.info(this.data);
// For Demo
if(this.data == undefined){
alert("Can not access Data Array");
return;
}
// swap
var oldElement = this.data[e.oldIndex];
this.data[e.oldIndex] = this.data[e.newIndex];
this.data[e.newIndex] = oldElement;
}
data = [
{ value: "Val 1" },
{ value: "Val 2"},
{ value: "Value 3"},
{ value: "Value 4"}
];
是否有解決方法,所以我可以訪問數組?
我這裏有一個例子:http://codepen.io/anon/pen/ozbRJA?editors=1010
'change'事件很可能在'Sortable'小部件的上下文中調用。像'this。$ angular_scope.ctrl.data'可能會有效。不幸的是我現在無法驗證它。 – Philipp
它就像一個魅力!在我的主項目中,我甚至還要做'this。$ angular_scope。$ parent.ctrl.data',但沒關係。謝謝! – webdude