Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'use strict';
  2. rootApp.filter('customerPassengerFilter', function() {
  3.     // return function(arr, searchString) {
  4.     //     if (!searchString) {
  5.     //         return arr;
  6.     //     }
  7.  
  8.  
  9.     //     function _findWord(word, str) {
  10.     //          str.split(' ').some(function(w) {
  11.     //              word.split(' ').some(function(s) {
  12.     //                 return w === s;
  13.     //             });
  14.     //         });
  15.     //     }
  16.  
  17.     //          console.log( arr.filter(function(filter){
  18.     //               _findWord(searchString, filter.reference_id)
  19.     //          }));
  20.     // };
  21.  
  22.     return function(arr, searchString) {
  23.         if (!arr) {
  24.             return searchString;
  25.         }
  26.  
  27.         var searchRegex = new RegExp(searchString, 'i');
  28.         return arr.filter(function(item, index) {
  29.                 return searchRegex.test(item.reference_id);
  30.  
  31.                 // если не найдено reference_id искать в объектах массива item.passengers с ключем
  32.                 // item.passengers[0].given_name item.passengers[1].given_name итд;
  33.         });
  34.     };
  35. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement