Q:

Angularjs : update variable using {{key}} inside ng-repeat

I set up an example to demonstrate my problem :
Here is the associated fiddle link : http://jsfiddle.net/kqw6N/
<div ng-app>
<span ng-init="myvar = {myattribute:'init'}">{{myvar.myattribute}}</span>
<table ng-init="myarray = {'key1': 'value1', 'key2': 'value2'}"><tbody>
    <tr>
        <td ng-repeat="(key, value) in myarray"  ng-click="myvar.myattribute='{{key}}'">
            {{value}}
            <span ng-click="myvar.myattribute='ok'">test</span>
        </td>
    </tr>
</tbody></table>
</div>

I would like to update myvar.myattribute while I click on the td inside ng-repeat. It works if I use a constant, but not if I use {{key}}.

A:

You don't need to embrace your key variable. You can access it as follows: 
<td ng-repeat="(key, value) in myarray"  ng-click="myvar.myattribute=key">

It's already in scope, so it will be found by angular. 

