// Define the AngularJS module var app = angular.module("exampleApp", []); // Define a service to manage items app.service("ItemService", function () { var items = ["Item 1", "Item 2", "Item 3"]; this.getItems = function () { return items; }; this.addItem = function (item) { items.push(item); }; }); // Define the main controller app.controller("MainController", function ($scope, ItemService) { $scope.title = "AngularJS Service Example"; $scope.description = "This example demonstrates how to use services in AngularJS."; $scope.items = ItemService.getItems(); $scope.addItem = function () { if ($scope.newItem) { ItemService.addItem($scope.newItem); $scope.newItem = ""; // Clear the input field after adding } }; });