Simply put, I'm using AngularJS trying to do something like this:
<ul>
<li ng-repeat="thing in things">
<a id="mybutton" href="link{{thing.Id}}">Click</a>
<script type="text/javascript">
$("#mybutton").click(function()
{
alert("Id: " + {{thing.Id}});
});
</script>
</li>
</ul>
Both that, and alert("Id: " + thing.Id); yield errors (unespected token '{' and 'thing' is not defined, respectively). Is there a way that I can access thing.Id from a block of javascript within the repeater's scope?
To add a practical reason, I'd like to build and redirect to a URL using that value and a few other things in javascript (where I have access to jquery).
Mike, using angular expressions ({{thing.id}}) in the tag won't work since angular.js is not a text-based template system but rather uses DOM as its templates. Here is more on this topic: http://docs.angularjs.org/guide/compiler
Now, coming back to your question: what you are trying to do can be done very easily in angular.js without using jQuery, here is a working jsFiddle: http://jsfiddle.net/pkozlowski_opensource/n6UfC/
The trick is to use a ng-click on your href:
<a ng-click="click(thing.id)">Click</a>
and then a click-handler function in your controller:
$scope.click = function(thingId) {
alert("Id: " + thingId);
//$location.path('/some/path/'+thingId);
}
In the controller's function you can use jQuery instructions but you would be better off using angular's $location service: http://docs.angularjs.org/api/ng.$location
I would store it to the element like "data-id={{thing.id}}"
Then from javascript read the ID back using the data attribute.