0


index.html:

<div ng-view="myview.html"></div>

myview.html:

<table class="table table-striped table-hover">
<tr>
<td>Name</td>
<td>Product</td>
</tr>
<tr ng-repeat="deal in deals" class="clickableRow">
<td>{{deal.name}}</td>
<td>{{deal.product}}</td>
</tr>
</table>

script.js:

$(document).ready(function($) {
      $(".clickableRow").click(function() {
            console.log("click");
      });
    }); // does nothing
console.log($(".clickableRow").length) // returns 0

I want to do some work when the user clicks on the clickableRows rows.

Thanks

1
  • your console.log is outside the $(document).ready so the table may not be loaded when the log line fires. - But you really could just use the ng-click from angular Commented Jul 14, 2014 at 11:50

1 Answer 1

1

why do you mix jquery and angularjs like this ? you can just do it with angularjs

<tr ng-repeat="deal in deals" ng-click="clickRow(deal)">

and in your controller

$scope.clickRow = function(deal) {
  console.log(deal)
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.