Ng-repeat id of button set?

Hello so my code is like this:

    <div ng-controller="courseCntr">
 <div ng-repeat="Course in CourseList">        
    <button class="button button-full button-stable">
       {{Course.CourseTitle}}
    </button>
    <div ng-repeat="Module in Course.Modules">
      <button class="button button-full button-stable">
        {{Module.Title}}
      </button>           
    </div>
  </ion-item>
 </div>

Question is how i can set and pass Id of button to ng-click funtion so i know witch one was clicked?

Hi, do the course and module objects have an ID field?

Could you do

<div ng-controller="courseCntr">
<div ng-repeat="Course in CourseList">        
<button ng-click="courseClick(course)" class="button button-full button-stable">
   {{Course.CourseTitle}}
</button>
<div ng-click="moduleClick(module)" ng-repeat="Module in Course.Modules">
  <button class="button button-full button-stable">
    {{Module.Title}}
  </button>           
</div>

Where courseClick() and moduleClick() are $scope functions that expect a course object and a module object respectively?

You can do something like this:

<div ng-repeat="Course in CourseList track by $index">
    <button id="course-{{ $index }}" class="button button-full button-stable" ng-click="someAction($index)">
        {{ Course.CourseTitle }}
    </button>
    <!-- More.. -->
</div>

Even simpler, if your courses have an id:

<button id="course-{{ $index }}" ng-click="someAction(Course.id)"></button>

Thanks for help guys :slight_smile: