I have an Angular App that uses Kendo some Kendo components and I'm having trouble with ng-repeat on a kendo dataSource object. These objects from the DataSource get injected into a Directive that uses the objects for rendering. Basically, the first added object added fine and then subsequent objects are entering the datasource but are not triggering the creation of more rows--- _until_ I interact with the _first_ object ie clicking it. Please help me to figure how to fix this problem.
Here is the ng-repeat:
<plate-builder ng-repeat="plate in plates.view()" plate="plate" modals="modals" plates="plates"> </plate-builder>
here is the directive code:
angular.module('plateApp.directives',['plateApp.services', 'plateApp.controllers'])
.directive('plateBuilder', [ 'createPlateService', function(){
return{
restrict : "AE",
scope : {
plate : "=plate",
plates : "=plates",
modals : "=modals"
},
templateUrl : "/ng/plate/partials/platePartial.html",
controller : 'PlateBuilder.plateCtl'
}
}])
I am adding objects to the datasource like this:
$scope.plates = new kendo.data.DataSource({
data : []
});
$scope.addNewPlate = function(){
$scope.plates.add(createPlateService.newPlate());
}
Here is the thing I am adding:
angular.module('plateApp.services',[])
.factory('createPlateService',['$http' ,'$log','$q',
function( $http, $log, $q){
var columns = ["1","2","3","4","5","6","7","8","9","10","11","12"];
var rows = ['A','B','C','D','E','F','G','H'];
var plate = {};
plate.grid = [];
plate.grid [0] = []
plate.grid [0][0] = { 'name' : '' , 'active' : false } ;
for( var i = 0 ; i < columns.length ; i += 1){
plate.grid[0][i+1] = {};
plate.grid[0][i+1].type = "col-label";
plate.grid[0][i+1].name = columns[i];
plate.grid[0][i+1].active = true ;
}
for ( var i = 0 ; i < rows.length ; i += 1 ){
plate.grid[i+1] = [];
plate.grid[i+1][0] = {};
plate.grid[i+1][0].type = "row-label";
plate.grid[i+1][0].name = rows[i];
plate.grid[i+1][0].active = true;
}
for (var i = 0 ; i < rows.length ; i += 1){
for ( var j = 0 ; j < columns.length ; j += 1){
plate.grid[i+1][j+1] = {};
plate.grid[i+1][j+1].name = "empty";
plate.grid[i+1][j+1].row = rows[i];
plate.grid[i+1][j+1].col = columns[j];
plate.grid[i+1][j+1].db_table = null;
plate.grid[i+1][j+1].id = null;
plate.grid[i+1][j+1].active = true;
}
}
plate.getCell = function( row , col ){
return plate.grid[row+1][col+1];
}
return {
newPlate : function(){
var rPlate = angular.copy(plate);
rPlate.created = new Date();
rPlate.sisUser = $('#sis-user').val();
rPlate.status = 'unsaved';
return rPlate
}
}
}])