Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8399459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:18:36+00:00 2026-06-09T21:18:36+00:00

I have an array of objects… for a concrete example, let’s call the array

  • 0

I have an array of objects… for a concrete example, let’s call the array People, where each person has a uniqueID, a name and a tagline.

I’m using the foreach templating to display a list of these people, like so:

<ul>
    <li ng-repeat="person in People">
        {{person.name}}: {{person.tagline}}
        ...

Simple enough to take the data from the controller and sync it into the model.

Now, I want to click on a person and do something complicated with their information. Like so:

<ul ng-controller="myCtrl">
    <li ng-repeat="person in People" ng-click="clickHandler($event)">
        ...

Right now, I have access to the DOM element like this:

$scope.clickHandler = function($event) {
    var domElement = $event.currentTarget;
        ...

But, how do I get the data from the relevant person object (the one that was clicked on), so that I can possibly look at their uniqueID (which is not stored in the DOM)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T21:18:38+00:00Added an answer on June 9, 2026 at 9:18 pm

    Whenever you use ng-repeat you should remember that it creates a new scope. This scope inherits from the parent scope. But for each item in ng-repeat a new scope is created.

    In order to access this scope you will also have to introduce a controller which will work along with that scope. So you would have to do

     <li ng-repeat="person in People" ng-click="clickHandler($event)" ng-controller="PersonController">
     ...
    

    In your javascript

    function PersonController($scope){
      //In here you will be able to access the person from "person in People"
    
      $scope.clickHandler = function($event){
        console.log($scope.person);    
      }
    }
    

    It is this scope that will have the person variable. Now, you could also declare a clickHandler here.

    You should note that for each person in People a new scope will be created as well as a new Controller (PersonController ). And in your person controller you will be able to access and manipulate your person to your hearts content.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array of objects . Each object has an attribute we'll call
I have array of Objects (let say that class name is Snap) Snap. Is
I have array of objects person (int age; String name;) . How can I
i have a array of objects, for example people and info about them. how
I have an array of objects created from a custom class. Each object has
When I have array of objects, when I type the name of variable in
I have an array of Objects, each containing a Location and a Links array
I have an array of objects: var countries = [ {'id': 35, 'name': 'Перу'},
I have an array of objects and I am trying to reference the name
I have an array of objects (A) which has an array of objects (B)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.