<!DOCTYPE html>
<
html
ng-app
=
"myApp"
>
<
head
>
<
meta
name
=
"viewport"
content="
width
=
device
-width,
initial-scale
=
1
">
<
link
rel
=
"stylesheet"
href
=
<
script
src
=
</
script
>
<
style
>
body {
font-family: Arial, sans-serif;
background-color: #f5f5f5;
margin: 0;
padding: 0;
}
.header {
text-align: center;
padding: 20px;
margin: 0;
}
.header h1 {
color: #4CAF50;
font-size: 36px;
margin: 0;
font-weight: bold;
}
.sub-header {
text-align: center;
color: #333;
font-size: 20px;
margin: 0;
padding: 10px;
font-weight: bold;
}
.filter-input {
width: 100%;
padding: 10px;
margin: 10px 0;
border: 1px solid #ccc;
border-radius: 5px;
}
.article-list {
list-style-type: none;
padding: 0;
margin: 20px;
}
.article-item {
margin: 10px 0;
padding: 10px;
background-color: #ffffff;
border-radius: 5px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.article-item:hover {
background-color: #f2f2f2;
transition: background-color 0.3s ease;
}
@media (max-width: 767px) {
.filter-input {
margin: 10px 0 0;
}
}
</
style
>
</
head
>
<
body
>
<
div
ng-controller
=
"myController"
>
<
div
class
=
"container"
>
<
div
class
=
"header"
>
<
h1
>GeeksforGeeks</
h1
>
</
div
>
<
div
class
=
"sub-header"
>
<
h3
>
Approach 2: Using a Custom
Filter Function
</
h3
>
</
div
>
<
div
class
=
"row"
>
<
div
class
=
"col-md-4"
>
<
input
class
=
"filter-input"
type
=
"text"
ng-model
=
"filter.title"
placeholder
=
"Filter by Title"
>
</
div
>
<
div
class
=
"col-md-4"
>
<
input
class
=
"filter-input"
type
=
"text"
ng-model
=
"filter.flavor"
placeholder
=
"Filter by Flavor"
>
</
div
>
<
div
class
=
"col-md-4"
>
<
input
class
=
"filter-input"
type
=
"text"
ng-model
=
"filter.rating"
placeholder
=
"Filter by Rating"
>
</
div
>
</
div
>
<
ul
class
=
"article-list"
>
<
li
class
=
"article-item"
ng-repeat
=
"article in filteredArticles"
>
<
strong
>{{article.title}}</
strong
>
(Flavor: {{article.flavor}},
Rating: {{article.rating}})
</
li
>
</
ul
>
</
div
>
</
div
>
<
script
>
var app = angular.module('myApp', []);
app.controller('myController', function ($scope) {
$scope.articles = [
{ title: 'AngularJS Introduction',
flavor: 'Frontend',
rating: 4.5 },
{ title: 'Node.js Basics',
flavor: 'Backend',
rating: 4.2 },
{ title: 'React vs. Angular Comparison',
flavor: 'Frontend',
rating: 4.8 },
{ title: 'JavaScript Fundamentals',
flavor: 'Frontend',
rating: 4.3 },
{ title: 'HTML5 and CSS3 Tutorial',
flavor: 'Frontend',
rating: 4.6 },
{ title: 'Python for Beginners',
flavor: 'Backend',
rating: 4.1 },
{ title: 'Data Structures in C++',
flavor: 'Programming',
rating: 4.7 },
{ title: 'Machine Learning with Python',
flavor: 'AI',
rating: 4.9 },
{ title: 'Web Development with React',
flavor: 'Frontend',
rating: 4.4 },
{ title: 'Java Programming Basics',
flavor: 'Backend',
rating: 4.0 },
{ title: 'C# for Beginners',
flavor: 'Backend',
rating: 4.2 },
{ title: 'Python Web Development',
flavor: 'Backend',
rating: 4.6 },
{ title: 'JavaScript Frameworks',
flavor: 'Frontend',
rating: 4.7 },
{ title: 'Advanced Machine Learning',
flavor: 'AI',
rating: 4.8 },
{ title: 'CSS Styling Techniques',
flavor: 'Frontend',
rating: 4.5 },
{ title: 'Algorithms and Data Structures',
flavor: 'Programming',
rating: 4.7 },
];
$scope.filteredArticles = $scope.articles;
$scope.filter = {};
$scope.$watchCollection('filter',
function (newVal, oldVal) {
$scope.filteredArticles =
$scope.articles.filter(function (article) {
return (!newVal.title ||
article.title.toLowerCase().
includes(newVal.title.toLowerCase())) &&
(!newVal.flavor ||
article.flavor.toLowerCase().
includes(newVal.flavor.toLowerCase())) &&
(!newVal.rating ||
article.rating.toString().includes(newVal.rating));
});
});
});
</
script
>
</
body
>
</
html
>