I create a directive to dynamically generate tables... the directive should contact the data service an then show some rows, the rows head is id, name, regions.
<planets data="{ view: 'planets', params: ['id','name','regions'] }"></planets>
test.directive('planets', function () {
return {
restrict: 'E',
scope: {
'data' : '='
},
template: '<div>{{data.params}}!</div>'
}
});
i need a advice how to generate the
<table>
<tr>
<th>id</th>
<th>name</th>
<th>regions</th>
</tr>
</table>
dynamic? and how to pass the data out of the service to the
iam not shur to use template or link?
thanks!
EDIT:
test.controller('projects', function ($scope, DataService, $resource) {
DataService.query(function(response) {
$scope.projects = response;
});
});
test.directive('planets', function () {
return {
restrict: 'E',
scope: {
'data' : '='
},
templateUrl: 'templates/table.html'
};
});
'data' : '='working for you?