I have an angularjs component that receives a json object as its input from another angular component. The ListView is initialized with the json object that is initially set as the input. However, when I change the json object from the main component, the data shown does not change even though the object itself has changed.
Below is my component code:
(
function
() {
'use strict'
;
var
app = angular.module(
'myModule'
);
function
myGroupCtrl() {
var
vm =
this
;
vm.sortableOptions = {
filter:
'.k-listview div.group'
};
vm.listOptions = {
dataSource:
new
kendo.data.DataSource({
data: vm.groups
})
};
vm.$onChanges =
function
(changes) {
console.log(vm.groups);
// new data
console.log(vm.listOptions.dataSource.data());
// original data
}
}
app.component(
'myGroupComponent'
, {
controller: [
myGroupCtrl
],
controllerAs:
'vm'
,
templateUrl:
'app/myGroups.html'
,
pageable:
true
,
transclude:
true
,
bindings: {
groups:
'<'
}
});
})();
<
kendo-sortable
options
=
"vm.sortableOptions"
>
<
kendo-list-view
id
=
"groups"
options
=
"vm.listOptions"
>
<
div
class
=
"group"
k-template>
<
span
class
=
"h4"
>
{{dataItem.groupName}}
</
span
>
</
div
>
</
kendo-list-view
>
</
kendo-sortable
>
I thought there might be a way to rebind or refresh the dataSource, but everything that I have tried gives me an error. I have used k-rebind on the grid. Is there something similar for ListView? Thanks!