Angular js Tables does not show rows

0

I'm starting with a sorting table and automatic filter with Angular. I want to use ng-table

The fact is that no matter how much I try I can not get the app to display rows, I get the format of the tables with its two input fields for the filters, but it does not show rows ..

Next the code

<body ng-app="main">

...

<div class="row" ng-controller="usuariosController as users">
                <table ng-table="tableParams" class="table" show-filter="true">
                    <tr ng-repeat="user in users.data">
                        <td title="'Name'" filter="{ name: 'text'}" sortable="'name'">
                            {{user.name}}</td>
                        <td title="'Age'" filter="{ age: 'number'}" sortable="'age'">
                            {{user.age}}</td>
                    </tr>
                </table>
            </div>

....

        (function () {
        'use strict';

        var myApp = angular.module('main', ['ngTable']);

        myApp.controller('usuariosController', function (NgTableParams) {


            var self = this;
            var data = [{name: "Moroni", age: 50},
                {name: "Simon", age: 43},
                {name: "Jacob", age: 27},
                {name: "Nephi", age: 29},
                {name: "Christian", age: 34},
                {name: "Tiancum", age: 43},
                {name: "Jacob", age: 27}];
                self.tableParams = new NgTableParams({ count: 5}, { counts: [5, 10, 25], dataset: data});

            ;
        });
    })();
    
asked by web developing 19.06.2017 в 10:34
source

2 answers

0

Well, I have found a solution. For those interested, you can see the following codepen

    
answered by 19.06.2017 / 11:07
source
0

It is solved by injecting $ scope inside the function part of the controller, so that you can correctly use ng-repeat in the view. In this way <tr ng-repeat="user in $data"> and having your controller like this:

var app = angular.module("MyApp", ["ngTable"]);

app.controller('usuariosController', function ($scope, NgTableParams) { var self = this; var data = [{name: "Moroni", age: 50}, {name: "Simon", age: 43}, {name: "Jacob", age: 27}, {name: "Nephi", age: 29}, {name: "Christian", age: 34}, {name: "Tiancum", age: 43}, {name: "Jacob", age: 27}]; self.tableParams = new NgTableParams({}, { dataset: data });   console.log(self.tableParams) });

    
answered by 19.06.2017 в 18:03