Saturday 15 March 2014

Smart-Table - AngularJs - Wrap within a directive -



Smart-Table - AngularJs - Wrap within a directive -

i'm new angularjs , trying "wrap" smart-table plugin within directive. can rows pagination not showing

currently did.

app.directive('grid', [ function () { homecoming { restrict: 'e', replace: true, template: function (element, attrs) { homecoming '<table class="table table-striped">' + '<thead>' + ' <tr>' + '<th st-ratio="20" st-sort="team">team</th>' + '<th st-ratio="20" st-sort="teamfreq">team freq</th>' + '<th st-ratio="10" st-sort="teamsac">team sac</th>' + '<th st-ratio="30" st-sort="priority">priority</th>' + '</tr>' + '</thead>' + '<tbody>' + '<tr ng-repeat="row in dataset">' + ' <td>{{row.firstname}}</td>' + '<td>{{row.lastname | uppercase}}</td>' + '<td>{{row.age}}</td>' + '<td>{{row.email}}</td>' + '</tr>' + '</tbody>' + '<tfoot>' + '<tr>' + '<td colspan="4" class="text-center">' + '<div class="pagination pagination-xs m-top-none pull-right" st-pagination="1" st-items-by-page="itemsbypage" st-displayed-pages="4"></div>' + '</td>' + '</tr>' + '</tfoot>' + '</table>'; }, scope: { }, controller: function ($scope) { }, link: function (scope, elem, attrs) { var namelist = ['pierre', 'pol', 'jacques', 'robert', 'elisa'], familyname = ['dupont', 'germain', 'delcourt', 'bjip', 'menez']; function createrandomitem() { var firstname = namelist[math.floor(math.random() * 4)], lastname = familyname[math.floor(math.random() * 4)], age = math.floor(math.random() * 100), email = firstname + lastname + '@@whatever.com', balance = math.random() * 3000; homecoming { firstname: firstname, lastname: lastname, age: age, email: email, balance: balance }; } scope.rowcollection = []; (var j = 0; j < 10; j++) { scope.rowcollection.push(createrandomitem()); } scope.dataset = [].concat(scope.rowcollection); } }; }]);

my html contains tag

<grid st-table="dataset"></grid>

this code test, info passed using service.. , template dynamic. need help :-)

thanks

i couldn't pagination show when using smart-table in directive other day. turns out had nil directive , pulled/updated latest version of smart-table github , worked. started looking @ had changed got side tracked , moved onto more productive, happy working. version have appears working fine tagged 1.4.2.

with dynamic info service, however, think you're going need @ st-safe-src attribute too. although i'm new whole angular / smart-table business too.

angularjs angularjs-directive smart-table

No comments:

Post a Comment