javascript - AngularJS filtering by code -
i'm working angularjs. how can search code
? current implementation searches ever type: id , name, city, code... how can search code?
app.js:
var app = angular.module('stack', []); app.directive('filterlist', function ($timeout) { return { link: function (scope, element, attrs) { var td = array.prototype.slice.call(element[0].children); function filterby(value) { td.foreach(function (el) { el.classname = el.textcontent.tolowercase().indexof(value.tolowercase()) !== -1 ? '' : 'ng-hide'; }); } scope.$watch(attrs.filterlist, function (newval, oldval) { if (newval !== oldval) { filterby(newval); } }); } }; });
example on jsfiddle
var app = angular.module('stack', []); app.directive('filterlist', function ($timeout) { return { link: function (scope, element, attrs) { var td = array.prototype.slice.call(element[0].children); function filterby(value) { td.foreach(function (el) { el.classname = el.cells[3].textcontent.tolowercase().indexof(value.tolowercase()) !== -1 ? '' : 'ng-hide'; }); } scope.$watch(attrs.filterlist, function (newval, oldval) { if (newval !== oldval) { filterby(newval); } }); } }; });
Comments
Post a Comment