aboutsummaryrefslogtreecommitdiffstats
path: root/src/widgets.js
diff options
context:
space:
mode:
authorVojta Jina2011-11-29 21:51:59 -0800
committerVojta Jina2012-01-23 11:05:36 -0800
commit992c790f0786fa45c1cc3710f29bf49c7c322ba7 (patch)
tree581d06ea9ba275a14d5891d83b2df03f9930bd45 /src/widgets.js
parentf5343c9fd3c7cd0fefdb4d71d2b579dbae998d6a (diff)
downloadangular.js-992c790f0786fa45c1cc3710f29bf49c7c322ba7.tar.bz2
refactor(scope): separate controller from scope
Controller is standalone object, created using "new" operator, not messed up with scope anymore. Instead, related scope is injected as $scope. See design proposal: https://docs.google.com/document/pub?id=1SsgVj17ec6tnZEX3ugsvg0rVVR11wTso5Md-RdEmC0k Closes #321 Closes #425 Breaks controller methods are not exported to scope automatically Breaks Scope#$new() does not take controller as argument anymore
Diffstat (limited to 'src/widgets.js')
-rw-r--r--src/widgets.js20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/widgets.js b/src/widgets.js
index 09a800de..6b3e93ee 100644
--- a/src/widgets.js
+++ b/src/widgets.js
@@ -54,11 +54,11 @@
<doc:example>
<doc:source jsfiddle="false">
<script>
- function Ctrl() {
- this.templates =
+ function Ctrl($scope) {
+ $scope.templates =
[ { name: 'template1.html', url: 'examples/ng-include/template1.html'}
, { name: 'template2.html', url: 'examples/ng-include/template2.html'} ];
- this.template = this.templates[0];
+ $scope.template = $scope.templates[0];
}
</script>
<div ng:controller="Ctrl">
@@ -171,9 +171,9 @@ angularWidget('ng:include', function(element){
<doc:example>
<doc:source>
<script>
- function Ctrl() {
- this.items = ['settings', 'home', 'other'];
- this.selection = this.items[0];
+ function Ctrl($scope) {
+ $scope.items = ['settings', 'home', 'other'];
+ $scope.selection = $scope.items[0];
}
</script>
<div ng:controller="Ctrl">
@@ -701,10 +701,10 @@ angularWidget('ng:view', function(element) {
<doc:example>
<doc:source>
<script>
- function Ctrl() {
- this.person1 = 'Igor';
- this.person2 = 'Misko';
- this.personCount = 1;
+ function Ctrl($scope) {
+ $scope.person1 = 'Igor';
+ $scope.person2 = 'Misko';
+ $scope.personCount = 1;
}
</script>
<div ng:controller="Ctrl">