Skip to content

Instantly share code, notes, and snippets.

@mhevery
Created August 29, 2010 18:48
Show Gist options
  • Save mhevery/556555 to your computer and use it in GitHub Desktop.
Save mhevery/556555 to your computer and use it in GitHub Desktop.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns:ng="http://angularjs.org">
<head>
<script type="text/javascript" src="http://angularjs.org/ng/js/angular-debug.js" ng:autobind></script>
<script>
function Texts(){
this.items = [];
}
Texts.prototype.addText = function(){
this.items.push(new Text());
}
function Text(){
}
Text.prototype.copy = function() {
this.contentCopy = angular.copy(this.content);
}
</script>
</head>
<body>
<div ng:controller="Texts">
<button type="submit" ng:click="addText()">more!</button>
<ul id="texts">
<div ng:repeat="text in items">
<li ng:controller="Text">
<button ng:click="text.copy()">copy</button>
<button ng:click="items.$remove(text)">delete</button>
<input name="text.content" type="text"/> -&gt; {{text.contentCopy}}
</li>
</div>
</ul>
</div>
<hr/>
<!--Debug View:-->
<pre>items={{items}}</pre>
<!-- -->
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment