Angular: Inline edit

http://angularjs.org/

by vojtajina

HTML

<script src="http://code.angularjs.org/0.10.6/angular-0.10.6.js"></script>
<div ng:repeat="i in items">
    <span ng:click="edit=true" ng:hide="edit">{{i.name}}</span>
    <input type="text" ng:model="i.name" ng:show="edit" />
    <button ng:show="edit" ng:click="edit=!edit">ok</button>
</div>

<input type="text" ng:model="newItem" /><button ng:click="add()">ADD</button>

JavaScript

function Main() {
    this.items = [
        {name: 'one'},
        {name: 'two'},
        {name: 'three'}
    ];
    this.add = function() {
        this.items.push({name: this.newItem});
        this.newItem = '';
    };
}