@@ -38,26 +38,26 @@ arrangement isolates the controller from the directive as well as from DOM. This
38
38
point since it makes the controllers view agnostic, which greatly improves the testing story of
39
39
the applications.
40
40
41
- <doc- example>
42
- <doc-source >
43
- <script>
44
- function MyController( $scope) {
45
- $scope.username = 'World';
46
-
47
- $scope.sayHello = function() {
48
- $scope.greeting = 'Hello ' + $scope.username + '!' ;
49
- };
50
- }
51
- </script >
41
+ <example>
42
+ <file name="script.js" >
43
+ function MyController($scope) {
44
+ $scope.username = 'World';
45
+
46
+ $scope.sayHello = function() {
47
+ $scope.greeting = 'Hello ' + $scope.username + '!';
48
+ } ;
49
+ }
50
+ </file>
51
+ <file name="index.html" >
52
52
<div ng-controller="MyController">
53
53
Your name:
54
54
<input type="text" ng-model="username">
55
55
<button ng-click='sayHello()'>greet</button>
56
56
<hr>
57
57
{{greeting}}
58
58
</div>
59
- </doc-source >
60
- </doc- example>
59
+ </file >
60
+ </example>
61
61
62
62
In the above example notice that the `MyController` assigns `World` to the `username` property of
63
63
the scope. The scope then notifies the `input` of the assignment, which then renders the input
@@ -117,26 +117,26 @@ inheritance, and child scopes prototypically inherit from their parents.
117
117
118
118
This example illustrates scopes in application, and prototypical inheritance of properties.
119
119
120
- <doc- example>
121
- <doc-source >
122
- <style>
123
- /* remove .doc-example-live in jsfiddle */
124
- .doc-example-live .ng-scope {
125
- border: 1px dashed red;
126
- }
127
- </style >
128
- <script>
129
- function EmployeeController( $scope) {
130
- $scope.department = 'Engineering';
131
- $scope.employee = {
132
- name: 'Joe the Manager',
133
- reports: [
134
- {name: 'John Smith'},
135
- {name: 'Mary Run'}
136
- ]
137
- };
138
- }
139
- </script >
120
+ <example>
121
+ <file name="style.css" >
122
+ /* remove .doc-example-live in jsfiddle */
123
+ .doc-example-live .ng-scope {
124
+ border: 1px dashed red;
125
+ }
126
+ </file>
127
+ <file name="script.js" >
128
+ function EmployeeController($scope) {
129
+ $scope.department = 'Engineering';
130
+ $scope.employee = {
131
+ name: 'Joe the Manager',
132
+ reports: [
133
+ {name: 'John Smith'},
134
+ {name: 'Mary Run'}
135
+ ]
136
+ };
137
+ }
138
+ </file>
139
+ <file name="index.html" >
140
140
<div ng-controller="EmployeeController">
141
141
Manager: {{employee.name}} [ {{department}} ]<br>
142
142
Reports:
@@ -148,8 +148,8 @@ This example illustrates scopes in application, and prototypical inheritance of
148
148
<hr>
149
149
{{greeting}}
150
150
</div>
151
- </doc-source >
152
- </doc- example>
151
+ </file >
152
+ </example>
153
153
154
154
Notice that the Angular automatically places `ng-scope` class on elements where scopes are
155
155
attached. The `<style>` definition in this example highlights in red the new scope locations. The
@@ -185,16 +185,16 @@ Scopes can propagate events in similar fashion to DOM events. The event can be {
185
185
api/angular.module.ng.$rootScope.Scope#$broadcast broadcasted} to the scope children or {@link
186
186
api/angular.module.ng.$rootScope.Scope#$emit emitted} to scope parents.
187
187
188
- <doc- example>
189
- <doc-source >
190
- <script>
191
- function EventController( $scope) {
192
- $scope.count = 0;
193
- $scope.$on('MyEvent', function() {
194
- $scope.count++ ;
195
- });
196
- }
197
- </script >
188
+ <example>
189
+ <file name="script.js" >
190
+ function EventController($scope) {
191
+ $scope.count = 0;
192
+ $scope.$on('MyEvent', function() {
193
+ $scope.count++;
194
+ }) ;
195
+ }
196
+ </file>
197
+ <file name="index.html" >
198
198
<div ng-controller="EventController">
199
199
Root scope <tt>MyEvent</tt> count: {{count}}
200
200
<ul>
@@ -211,8 +211,8 @@ api/angular.module.ng.$rootScope.Scope#$emit emitted} to scope parents.
211
211
</li>
212
212
</ul>
213
213
</div>
214
- </doc-source >
215
- </doc- example>
214
+ </file >
215
+ </example>
216
216
217
217
218
218
0 commit comments