given this jsfiddle: http://jsfiddle.net/HB7LU/1356/
I have an array of objects retrieved from my service. I then build an html string with links created around those items that exist in the array. I want the click handler to be bound directly to item in the array. The behavior I'm after is the way an object can be passed directly into a ngClick when used within a ngRepeat.
//these were retrieved from a service first
$scope.termsToBindTo = [
{name: 'test 1', active: false },
{name: 'test 2', active: false },
{name: 'test 3', active: false }];
$scope.rawString = 'test 1, test 2, and test 3';
//then this html string was built after termsToBindTo is populated
$scope.myHTML = '<a href="#" ng-click="itemClicked(item)">test 1</a>, <a href="#" ng-click="itemClicked(item)">test 2</a>, and <a href="#" ng-click="itemClicked(item)">test 3</a>';
UPDATE: i added the rawString to the controller. I considered the suggestion below to just use ngRepeat over termsToBindTo but my view must present the links just as rawString looks. In other words I cannot just provide a list of termsToBindTo. The view has to provide the links with any formatting or punctuation that exist in rawString.