How To Build A Full Dynamic Template In Angular?
I want to ask the community of angular to help me to find the best way to solve this problem : I have data like this in json : { 'id': '0001', 'type': 'donut', 'name'
Solution 1:
Yes, you should create directive with field config like this:
var config = [{
title: 'Column name',
renderer: functionvalueRenderer(item){ return item.id}
}];
and render it like
<table><thead><thng-repeat="column in config"ng-bind="column.title"></thead><tbody><trng-repeat="item in data"><tdng-repeat="column in config"ng-bind="column.renderer(item)"></td></tr></tbody></table>
and wrap it inside directive
<my-dirconfig="ctrl.config"data="ctrl.data"></my-dir>
directive:
module.directive('myDir', function(){
return {
restrict: 'E',
scope: {
data: '=',
config: '='
},
template: '<table ....'
};
});
Post a Comment for "How To Build A Full Dynamic Template In Angular?"