Skip to content

Instantly share code, notes, and snippets.

@ejain
Created February 12, 2012 01: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 ejain/1805728 to your computer and use it in GitHub Desktop.
Save ejain/1805728 to your computer and use it in GitHub Desktop.
<!doctype html>
<html xmlns:ng="http://angularjs.org" ng:app>
<head>
<script src="http://docs-next.angularjs.org/angular-0.10.6.min.js"></script>
<script>
function MainCtrl() {
self = this;
this.name = 'Main';
this.filter = [ ]
this.result = { };
this.search = function() {
for (var i = 0; i < self.filter.length; ++i) {
self.result[self.filter[i]] = Math.floor(Math.random() * 100);
}
}
}
function FooCtrl() {
this.name = 'Foo';
this.filter.push('foo');
}
function BarCtrl() {
this.name = 'Bar';
this.filter.push('bar');
}
function DummyCtrl() { }
</script>
</head>
<body ng:controller="MainCtrl">
<p>Filters for {{name}} are {{filter.join(', ')}}.</p>
<div ng:controller="FooCtrl">
<p>Result for {{name}} is {{result.foo}}.</p>
</div>
<div ng:controller="BarCtrl">
<p>Result for {{name}} is {{result.bar}}.</p>
</div>
<div ng:controller="DummyCtrl" ng:init="search()"/>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment