Skip to content

Commit 3c87611

Browse files
committed
docs - various doc fixes
1 parent b842642 commit 3c87611

File tree

3 files changed

+29
-55
lines changed

3 files changed

+29
-55
lines changed

docs/content/guide/dev_guide.compiler.extending_compiler.ngdoc

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,61 +3,54 @@
33
@name Developer Guide: Angular HTML Compiler: Extending the Angular Compiler
44
@description
55

6-
76
Let's say that we want to create a new DOM element called `<my:greeter/>` that displays a greeting.
87
We want this HTML source:
98

10-
119
<pre>
12-
<div ng:init="salutation='Hello'; name='World'">
13-
<my:greeter salutation="salutation" name="name"/>
14-
</div>
10+
<div ng:init="s='Hello'; n='World'">
11+
<my:greeter salutation="s" name="n"/>
12+
</div>
1513
</pre>
1614

17-
1815
to produce this DOM:
1916

20-
2117
<pre>
22-
<div ng:init="salutation='Hello'; name='World'">
23-
<my:greeter salutation="salutation" name="name"/>
18+
<div ng:init="s='Hello'; n='World'">
19+
<my:greeter salutation="s" name="n"/>
2420
<span class="salutation">Hello</span>
2521
<span class="name">World</span>!
2622
</my:greeter>
2723
</div>
2824
</pre>
2925

30-
3126
That is, the new `<my:greeter/>` tag's `salutation` and `name` attributes should be transformed by
3227
the compiler such that two `<span>` tags display the values of the attributes, with CSS classes
3328
applied to the output.
3429

35-
3630
The following code snippet shows how to write a following widget definition that will be processed
3731
by the compiler. Note that you have to declare the {@link dev_guide.bootstrap namespace} `my` in
3832
the page:
3933

40-
4134
<pre>
4235
angular.widget('my:greeter', function(compileElement){
43-
var compiler = this;
44-
compileElement.css('display', 'block');
45-
var salutationExp = compileElement.attr('salutation');
46-
var nameExp = compileElement.attr('name');
47-
return function(linkElement){
48-
var salutationSpan = angular.element('<span class="salutation"></span');
49-
var nameSpan = angular.element('<span class="name"></span>');
50-
linkElement.append(salutationSpan);
51-
linkElement.append(compiler.text(' '));
52-
linkElement.append(nameSpan);
53-
linkElement.append(compiler.text('!'));
54-
this.$watch(salutationExp, function(value){
55-
salutationSpan.text(value);
56-
});
57-
this.$watch(nameExp, function(value){
58-
nameSpan.text(value);
59-
});
60-
};
36+
var compiler = this;
37+
compileElement.css('display', 'block');
38+
var salutationExp = compileElement.attr('salutation');
39+
var nameExp = compileElement.attr('name');
40+
return function(linkElement){
41+
var salutationSpan = angular.element('<span class="salutation"></span');
42+
var nameSpan = angular.element('<span class="name"></span>');
43+
linkElement.append(salutationSpan);
44+
linkElement.append(compiler.text(' '));
45+
linkElement.append(nameSpan);
46+
linkElement.append(compiler.text('!'));
47+
this.$watch(salutationExp, function(value){
48+
salutationSpan.text(value);
49+
});
50+
this.$watch(nameExp, function(value){
51+
nameSpan.text(value);
52+
});
53+
};
6154
});
6255
</pre>
6356

docs/content/guide/dev_guide.unit-testing.ngdoc

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,11 @@ function MyClass(xhr) {
150150
}
151151
</pre>
152152

153-
154-
This is the proferred way since the code makes no assumptions as to where the `xhr` comes from,
155-
rather that who-ever crated the class was responsible for passing it in. Since the creator of the
156-
class should be different code the the user of the class, it separates the responsibility of
153+
This is the preferred way since the code makes no assumptions as to where the `xhr` comes from,
154+
rather that whoever created the class was responsible for passing it in. Since the creator of the
155+
class should be different code than the user of the class, it separates the responsibility of
157156
creation from the logic, and that is what dependency-injection is in a nutshell.
158157

159-
160158
The class above is very testable, since in the test we can write:
161159
<pre>
162160
function xhrMock(args) {...}
@@ -165,21 +163,16 @@ myClass.doWork();
165163
// assert that xhrMock got called with the right arguments
166164
</pre>
167165

168-
169166
Notice that no global variables were harmed in the writing of this test.
170167

171-
172-
Angular comes with {@link dev_guide.di dependency-injection} built in which makes the right thin
173-
the easy thing to do, but you still need to do it if you wish to take advantage of the testability
174-
story.
175-
168+
Angular comes with {@link dev_guide.di dependency-injection} built in which makes the right thing
169+
easy to do, but you still need to do it if you wish to take advantage of the testability story.
176170

177171
## Controllers
178172
What makes each application unique is its logic, which is what we would like to test. If the logic
179173
for your application is mixed in with DOM manipulation, it will be hard to test as in the example
180174
below:
181175

182-
183176
<pre>
184177
function PasswordController(){
185178
// get references to DOM elements

docs/content/tutorial/step_09.ngdoc

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,46 +88,34 @@ describe('checkmark filter', function() {
8888
})
8989
</pre>
9090

91-
9291
To run the unit tests, execute the `./scripts/test.sh` script and you should see the following
9392
output.
9493

95-
9694
Chrome: Runner reset.
9795
....
9896
Total 4 tests (Passed: 4; Fails: 0; Errors: 0) (3.00 ms)
9997
Chrome 11.0.696.57 Mac OS: Run 4 tests (Passed: 4; Fails: 0; Errors 0) (3.00 ms)
10098

10199

102-
103-
104100
# Experiments
105101

106-
107102
* Let's experiment with some of the {@link api/angular.filter built-in angular filters} and add the
108103
following bindings to `index.html`:
109104
* `{{ "lower cap string" | uppercase }}`
110105
* `{{ {foo: "bar", baz: 23} | json }}`
111106
* `{{ 1304375948024 | date }}`
112-
* `{{ 1304375948024 | date:"'MM/dd/yyyy @ h:mma" }}`
113-
107+
* `{{ 1304375948024 | date:"MM/dd/yyyy @ h:mma" }}`
114108

115109
* We can also create a model with an input element, and combine it with a filtered binding. Add
116110
the following to index.html:
117111

118-
119112
<input name="userInput"> Uppercased: {{ userInput | uppercase }}
120113

121114

122-
123-
124115
# Summary
125116

126-
127117
Now that you have learned how to write and test a custom filter, go to step 10 to learn how we can
128118
use angular to enhance the phone details page further.
129119

130120

131-
132-
133121
<ul doc:tutorial-nav="9"></ul>

0 commit comments

Comments
 (0)