Skip to content

Instantly share code, notes, and snippets.

@mhevery
Created March 28, 2011 22:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhevery/891467 to your computer and use it in GitHub Desktop.
Save mhevery/891467 to your computer and use it in GitHub Desktop.
<html>
<head>
<script src="http://code.angularjs.org/angular-0.9.13.js" ng:autobind></script>
<script>
function MyCntrl($defer) {
var self = this;
this.list_of_items = ['this', 'that', 'the other'];
self.foo = {choice:''};
$defer(function(){
self.foo = {choice:'that'};
});
}
MyCntrl.prototype = {
loadData: function(){
this.foo = {choice:'that'};
}
}
</script>
</head>
<body ng:controller="MyCntrl">
<ul>
<li ng:repeat="item in list_of_items">
<input type="radio" name="foo.choice" value="{{item}}"
id="item_{{$index}}">
<label for="item_{{$index}}">
<code>{{item}}</code>
</label>
</li>
<a class="action" href="" ng:click="loadData()">Load</a>
</ul>
choice: {{foo}}
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment