Created
February 12, 2012 01:44
-
-
Save ejain/1805728 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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