Open In App
Related Articles

How to search special character in an angular smart table?

Like Article
Save Article
Report issue

Introduction on Smart table:

It is an Angularjs module used for display purpose as a table format with a set of features like filtering, sorting, etc., This is very much helpful during report preparation, filtering and searching of data in a quicker manner in angular js. It is lightweight, developer-friendly, robust, modular, and extensible


  • We can start using smart table by using the below ways
  • bower install angular-smart-table (or)
  • npm install angular-smart-table
  • Once the above scripts are executed, we are set in using angular-smart-table


  1. Add the module angular.module(‘<nameofyourapp>’, [‘smart-table’] to the angular application.
  2. Just like following normal html table structure, on the table element, need to  add the “st-table” attribute to inform smart-table about the collection that will display the  data, (i.e., using repeater)
  3. For Searching a content in angular-smart-table, we need to use, stSearch directive. It can be a comma-separated list of search items that need to be searched
  4. stDebounceTime attribute (the value is in millisecond) can be used in order to control the searching time. Sometimes useless calls will be made (when especially connected to the server) and in order to overcome, this attribute is needed.
  5. During search, the input can be a regular expression pattern. Sometimes, in order to escape regexp specific characters in the input, we need to use stSearchEscape attribute.

Basic Examples and Explanations:

Let us see the sample code of searching in the smart table along with filtering and pagination is seen in below code

Data is retrieved from “” for our sample

stSafeSrc attribute:

As we have taken data from the restful endpoint (even from a remote database, restful endpoint, ajax call, etc) we need to use this attribute without fail. Moreover smart table creates a copy of the displayed collection and since asynchronous data is involved, this attribute is a must.

Here “employees” retrieved as asynchronously and need to be rendered and it is specified in st-safe-src

sort is applied on all columns and hence st-sort is given for sorting.

pagination is applied to have 5 records per page.

Input :

With the above approaches, let us render the data in a smart table with search, sort, and pagination functionalities

SampleApp = angular.module(
'SampleApp', ['SampleApp.controllers', 'smart-table']);    
angular.module('SampleApp.controllers', []).controller(
['$scope', '$http', function($scope, $http) 
    $scope.loading = false;
    $scope.getData = function() {
        $scope.loading = true;
            $scope.employees =;
            $scope.loading = false;

<!DOCTYPE html>
        <meta http-equiv="Content-Type" 
              content="text/html; charset=utf-8" />
        <link rel="stylesheet"
        <script src=
        <script src=
        <link rel="stylesheet" 
        <!-- Indication to know we are
              using smartTableApp.js -->
        <script src="smartTableApp.js">
        <!-- Including our SampleApp and 
             iterate in Angular JS  -->
        <div class="container" 
            <h2>Angular Smart Table Example with
              Pagination, Search and Sorting in 
              a simpler way</h2>
            <div ng-show="loading"><h3>Loading the data...</h3>
            <table st-table="displayEmployee" 
                   class="table table-striped">
                        <th colspan="1">
                            <input st-search placeholder=
                                   "Please provide data to search" 
                                   class="input-sm form-control" 
                                   type="search" />
                        <th st-sort="name">Employee Name</th>
                        <th st-sort="gender">Gender</th>
                        <th st-sort="age">Employee Age</th>
                        <th st-sort="skills">Skills</th>
                        <th st-sort="designation">
                          Employee Designation</th>
                    <tr st-select-row="row"
                        ng-repeat="employee in displayEmployee">
                        <td colspan="5" class="text-center">
                            <div st-pagination="" 

Output: After Searching a text Sorting based on Designation

Last Updated : 15 Sep, 2020
Like Article
Save Article
Share your thoughts in the comments
Similar Reads