Staff solved the problem with the code below:
Filter PHP list with angularJS
View the code here on the plunker
I happen to be having problems with words that are capitalized eg a word that is "Protocol" and I type "protocol", the filter does not find it.
app.js
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
$scope.model = {
filter: ''
};
});
app.directive('myHtmlFilter', [function() {
return {
restrict: 'A',
scope: {
filter: '=myHtmlFilter',
element: '@'
},
link: function(scope, elem, attrs) {
scope.$watch('filter', function(newval, oldval) {
elem
.find('ul>li')
.hide()
.find(scope.element)
.filter(':contains("'+scope.filter+'")')
.parent()
.show();
})
}
}
}]);
Index.html
<input type="text" ng-model="model.filter" />
<div my-html-filter="model.filter" element="h2">
<ul>
<li id="1">
<h2>Protocolo</h2>
<p>The Message...</p>
</li>
<li id="2">
<h2>My second Post</h2>
<p>The Message...</p>
</li>
<li id="3">
<h2>My third Post</h2>
<p>The Message...</p>
</li>
</ul>
</div>