Can a placeholder be set on the input to an ng table?

Is there a way to set a placeholder on the <input>

created in ngTable?

As a second option, is there any other way to set the input to work as a filter?

Changes to this would be appreciated. Thank!

+3


source to share


3 answers


You can edit ng-table.js

Unminify ng-table.js (i.e. http://jsbeautifier.org/ ) and after that on line 250 you can find

<input type="text" ng-model="params.filter()[name]" ng-if="filter==\'text\'" ,class="input-filter form-control"/>

      

add a placeholder, i.e .:



<input type="text" ng-model="params.filter()[name]" ng-if="filter==\'text\'" placeholder="input {{name}}",class="input-filter form-control"/>

      

See a working demo here:

http://plnkr.co/edit/q0CMCb7evmZh1sflVV5f?p=preview

+4


source


To avoid editing the ng-table.js file, you can add the following:

angular.module('ngTable').run(['$templateCache', function ($templateCache) {
  $templateCache.put('ng-table/filters/text.html', '<input type="text" ng-model="params.filter()[name]" ng-if="filter==\'text\'" placeholder="{{name}}" class="input-filter form-control"/>');
}]);

      



This will create a cached copy of the template used in the text "ng-table" ng-tables "ng-table / filters / text.html".

+2


source


Add new solution inside ng-table html, do something like this,

<td filter="{ address: {id:'text',placeholder:'ADDRESS'}}">{{row.address}}</td>

      

+1


source







All Articles