// Define the AngularJS module var app = angular.module("filterExampleApp", []); // Define a custom filter app.filter("filterByName", function () { return function (input, searchName) { if (!searchName) return input; var filtered = []; angular.forEach(input, function (user) { if (user.name.toLowerCase().indexOf(searchName.toLowerCase()) !== -1) { filtered.push(user); } }); return filtered; }; }); // Define the main controller app.controller("MainController", function ($scope) { // Initialize scope variables $scope.message = "Hello, AngularJS!"; // Array of users $scope.users = [ { name: "John Doe" }, { name: "Jane Smith" }, { name: "Michael Johnson" }, { name: "Emily Brown" }, { name: "David Williams" }, ]; });