Search code examples
javascriptangularjsangularjs-ng-repeatrestangularsmart-table

Smart-table search in table is not working


I try to display my data in a "smart-table", I use Restangular and data loaded to table very good, but search is not working(no data in table after query), Im new in angular(and in web too lol) and currently I realy don't know how to fix it. Below is my code and code from example(working correct). I will be very grateful to your advice.

My code(search is not working):

'use strict';

angular.module('NewApp')
  .controller('ItemsCtrl', function ($scope, Item) {
      $scope.items = Item.getList().$object;
  });

'Item' from app.js:

....
.factory('Item', function(ItemRestangular) {
    return ItemRestangular.service('item');
  });

Code from example(search work correct):

'use strict';
angular.module('NewApp')
  .controller('ItemsCtrl', function ($scope) {
    $scope.items = [
       {firstName: 'Laurent', lastName: 'Renard', birthDate: new Date('1987-05-21'), balance: 102, email: 'whatever@gmail.com'},
       {firstName: 'Blandine', lastName: 'Faivre', birthDate: new Date('1987-04-25'), balance: -2323.22, email: 'oufblandou@gmail.com'},
       {firstName: 'Francoise', lastName: 'Frere', birthDate: new Date('1955-08-27'), balance: 42343, email: 'raymondef@gmail.com'}
   ];
  });

html page:

        ...
        <tr ng-repeat="item in items">
            <td>{{item.firstName | uppercase}}</td>
            ...

Solution

  • If you post total smart table part in html, I can help you more effectively. If you would like to use search function on smart table,

    You need refer smart table module like this.

    angular.module('NewApp', ['smart-table']);
    

    And You should use st-search directive in input tag under st-table directive. Please confirm.

    <table st-table...>
     <tr>
      <th>
        <input st-search="" .../>
      </th>
     </tr>
    

    Thanks.