In AngularJS, you can use ng-repeat and ng-click in the same tag to repeat elements and handle click events on those elements. Here's an example of how you can do this:

html
<div ng-app="myApp" ng-controller="myController"> <ul> <!-- Using ng-repeat to repeat list items --> <li ng-repeat="item in items" ng-click="onClick(item)">{{ item }}</li> </ul> </div>
javascript
var app = angular.module('myApp', []); app.controller('myController', function($scope) { // Sample data for demonstration $scope.items = ['Item 1', 'Item 2', 'Item 3', 'Item 4']; // Function to handle click event with the item parameter $scope.onClick = function(item) { console.log('Clicked:', item); // Perform actions with the clicked item here }; });

In this example, we use ng-repeat to loop through the items array and display each item as a list item (<li>). Additionally, we use ng-click to handle the click event on each list item. When a list item is clicked, the onClick function is called with the corresponding item as the parameter.

When you run this code, you'll see a list of items, and when you click on any item, its value will be logged to the console.

Note that you can use ng-click with any HTML element to handle click events. The element doesn't have to be an <li>; it can be any valid HTML element like <button>, <div>, etc. The ng-repeat directive can be used to repeat elements inside any container element, such as <ul>, <ol>, <div>, etc.

Have questions or queries?
Get in Touch