title: AngularJS/Bootstrap - Select row and open details in modal with button
body: <p>I'm using AngularJS, Bootstrap, and data-toggle to open a modal. I want to click on a row in a table, get the index number and store it, and click a button to open a modal that displays more details for that row using the stored index.</p>
  
  <p>My code right now can get the index of the clicked row and my button opens a modal, but they're not connected so that the button grabs the row index and shows those details in the modal. My modal shows all row data instead of the details for the one clicked row. How can I connect the clicked row to the button and how do I get my modal to show details for one app instead of all apps? Any help would be much appreciated!</p>
  
  <p>Here is my <a href="http://jsfiddle.net/f5r5rxkz/" rel="nofollow">JS Fiddle</a>.</p>
  
  <p>Here is the code snippet for the click functions:</p>
  
  <pre><code>$scope.selectedRow = null;
  
  $scope.clickRow = function(index) {
      $scope.selectedRow = index;
      console.log(index);
  };
  
  $scope.getDetails = function(index) {
      $scope.selectedRow = index;
      console.log(index);
  };
  </code></pre>
  
  <p>And here is the code for my table and modal that call the click functions:</p>
  
  <pre><code>&lt;div id="tableDiv"&gt;
      &lt;table id="myTable" class="table display"&gt;
          &lt;thead&gt;
              &lt;tr&gt;
                  &lt;th ng-repeat="(i, th) in head" value="{{th.id}}" class="{{th.class}}"&gt;&lt;span&gt;{{th.name}}&lt;/span&gt;&lt;/th&gt;
              &lt;/tr&gt;
          &lt;/thead&gt;
          &lt;tbody&gt;
              &lt;tr ng-repeat="app in apps | filter:search" ng-click="clickRow($index)" ng-class="{selected: $index === selectedRow}"&gt;
                  &lt;td&gt;{{app.appName}}&lt;/td&gt;
                  &lt;td&gt;{{app.dateCreated}}&lt;/td&gt;
                  &lt;td&gt;{{app.dateUpdated}}&lt;/td&gt;
                  &lt;td&gt;{{app.payload}}&lt;/td&gt;
                  &lt;td&gt;{{app.status.name}}&lt;/td&gt;
                  &lt;td&gt;{{app.errorCode.name}}&lt;/td&gt;
                  &lt;td&gt;{{app.errorDesc}}&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/tbody&gt;
          &lt;tfoot&gt;
              &lt;tr&gt;
                  &lt;th ng-repeat="(i, th) in head" value="{{th.id}}"&gt;&lt;span&gt;{{th.name}}&lt;/span&gt;&lt;/th&gt;
              &lt;/tr&gt;
          &lt;/tfoot&gt;
      &lt;/table&gt;
  &lt;/div&gt;
  
  &lt;div id="details"&gt;
      &lt;button class="btn btn-default" data-toggle="modal" data-target="#myModal" ng-click="getDetails($index)"&gt;Launch&lt;/button&gt;
      &lt;div class="modal fade" id="myModal" tabindex="-1" role="dialog"
          aria-labelledby="myModalLabel" aria-hidden="true"&gt;
          &lt;div class="modal-dialog"&gt;
              &lt;div class="modal-content"&gt;
                  &lt;div class="modal-header"&gt;
                      &lt;button type="button" class="close" data-dismiss="modal"
                          aria-hidden="true"&gt;&amp;times;&lt;/button&gt;
                      &lt;h4 class="modal-title" id="myModalLabel"&gt;Details&lt;/h4&gt;
                  &lt;/div&gt;
                  &lt;div class="modal-body"&gt;
                      &lt;table class="table display"&gt;
                          &lt;thead&gt;
                              &lt;tr&gt;
                                  &lt;th ng-repeat="(i, th) in details" value="{{th.id}}"
                                      class="{{th.class}}"&gt;&lt;span&gt;{{th.name}}&lt;/span&gt;&lt;/th&gt;
                              &lt;/tr&gt;
                          &lt;/thead&gt;
                          &lt;tbody&gt;
                              &lt;tr ng-repeat="app in apps"&gt;
                                  &lt;td&gt;{{app.appName}}&lt;/td&gt;
                                  &lt;td&gt;{{app.errorDesc}}&lt;/td&gt;
                                  &lt;td&gt;{{app.recordCount}}&lt;/td&gt;
                                  &lt;td&gt;{{app.recordFail}}&lt;/td&gt;
                              &lt;/tr&gt;
                          &lt;/tbody&gt;
                      &lt;/table&gt;
                  &lt;/div&gt;
                  &lt;div class="modal-footer"&gt;
                      &lt;button type="button" class="btn btn-default" data-dismiss="modal"&gt;Close&lt;/button&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>