javascript - AngularJS & Datatable - Compile html while re-rendering the cell value -


i using angularjs , datatable build grid. have following javascript code,

demo: http://plnkr.co/edit/qj7vr1bec5odrrxphw2q?p=preview

datatable_config = {      "bjqueryui": true,      "bprocessing": true,      "bdeferrender": true,      "sdom": "rlfrtip",      "aadata": [null] };  angular.foreach(columns, function(column, key){     datatable_config.aocolumns.push({         "stitle": column.displayname,          "mdata": function(source, type, value){             var cell_value = (source[column.field]) ? source[column.field] : '', rendered_cell;             if(column.field == 'something'){                 rendered_cell = $compile('<span>{{$root.value}}</span>')($scope);                  /* column, not getting span element evaluated rootscope instead, says [object object] */             } else {                 rendered_cell = cell_value;             }             return rendered_cell;         }     }); }); 

when compile html, displays [object object]. getting problem, need compile after bind, element.html(value); $compile(element.contents())(scope);. not possible in above code. solution or idea?

thanks in advace.

had similar issue trying compile "to rendered dom". after hours made work, though requirements lot different. needed bind directives also, need use $compile().

for use case, use $parse

// parse "value" attribute value function var parsefn = $parse(value); // "parsefn" function can invoked expression's value  // providing scope var currval = parsefn($root);  // return updated markup return '<span>'+ currval +'</span>'; 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -