how to bind angularjs objects to their keys and values

Answer for SO Question: http://stackoverflow.com/questions/23643592/how-to-bind-angularjs-objects-to-their-keys-and-values

by Daniel Bank

HTML

<div ng-app>
<div ng-controller="ctrl">
     Using ngRepeat's $index property, I can control what value I'm showing in the second box by changing the index in the first box.  I can even create new key-value pairs by entering the new key in the index textbox. However the new key name is not preserved in the index textbox when I change its value (I have to retype the key name to recall the value).
    <div ng-repeat="value in obj">
        <input type="text" ng-model="$index"/>
        <input type="text" ng-model="obj[$index]"/>
        <input type="text" ng-model="value"/>
    </div>    
    {{obj}}
</div>
</div>

JavaScript

function ctrl($scope){
    $scope.obj = {
        '0': 'a',
        '1': 'b',
        '2': 'c',
        'George': 'Clooney',
    };
}