Skip to content

Commit a79231d

Browse files
committed
doc(guide): various fixes and improvements
1 parent 3e54a1b commit a79231d

7 files changed

+43
-53
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ We want this HTML source:
88

99
<pre>
1010
<div ng:init="s='Hello'; n='World'">
11-
<my:greeter salutation="s" name="n"/>
11+
<my:greeter salutation="s" name="n"></my:greeter>
1212
</div>
1313
</pre>
1414

@@ -23,9 +23,9 @@ to produce this DOM:
2323
</div>
2424
</pre>
2525

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

3030
The following code snippet shows how to write a following widget definition that will be processed
3131
by the compiler. Note that you have to declare the {@link dev_guide.bootstrap namespace} `my` in
@@ -41,9 +41,9 @@ angular.widget('my:greeter', function(compileElement){
4141
var salutationSpan = angular.element('<span class="salutation"></span');
4242
var nameSpan = angular.element('<span class="name"></span>');
4343
linkElement.append(salutationSpan);
44-
linkElement.append(compiler.text(' '));
44+
linkElement.append(' ');
4545
linkElement.append(nameSpan);
46-
linkElement.append(compiler.text('!'));
46+
linkElement.append('!');
4747
this.$watch(salutationExp, function(value){
4848
salutationSpan.text(value);
4949
});

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,9 @@ angular.markup('---', function(text, textNode, parentElement) {
5757
var compiler = this;
5858
var index = text.indexOf('---');
5959
if (index > -1) {
60-
var before = compiler.text(text.substring(0, index));
61-
var hr = compiler.element('hr');
62-
var after = compiler.text(text.substring(index + 3));
63-
textNode.after(after);
64-
textNode.after(hr);
65-
textNode.after(before);
60+
textNode.after(text.substring(index + 3));
61+
textNode.after(angular.element('<hr>'));
62+
textNode.after(text.substring(0, index));
6663
textNode.remove();
6764
}
6865
});

docs/content/guide/dev_guide.compiler.widgets.creating_widgets.ngdoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ expression and `alert()` the user with each new value:
1111

1212
<pre>
1313
// An element widget
14-
<my:watch exp="name"/>
14+
<my:watch exp="name"></my:watch>
1515
</pre>
1616

1717
You can implement `my:watch` like this:
@@ -36,16 +36,16 @@ Let's implement the same widget as in the example in Defining an Element Widget,
3636
an attribute that can be added to any existing DOM element:
3737

3838
<pre>
39-
// An attribute widget (my-watch) in a div tag
40-
<div my-watch="name">text</div>
39+
// An attribute widget (my:watch) in a div tag
40+
<div my:watch="name">text</div>
4141
</pre>
4242
You can implement `my:watch` attribute like this:
4343
<pre>
4444
angular.widget('@my:watch', function(expression, compileElement) {
4545
var compiler = this;
4646
return function(linkElement) {
4747
var currentScope = this;
48-
currentScope.$watch(expression, function(value){
48+
currentScope.$watch(expression, function(value) {
4949
alert(value);
5050
});
5151
};

docs/content/guide/dev_guide.di.understanding_di.ngdoc

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,8 @@ function fnB($window, serviceA_, name){};
8787
</pre>
8888

8989
If angular does not find a `$inject` annotation on the function, then it calls the `.toString()`
90-
method and tries to infer what should be injected using the following rules:
91-
92-
* Any argument starting with `$` is an angular service and will be added to the `$inject` property
93-
array
94-
* Any argument ending with `_` will be added to the `$inject` property array (angular strips the
95-
`_`)
96-
* All arguments following an argument which has neither `$` nor `_` , must not have `$` nor `_`
97-
(these are free arguments for {@link http://en.wikipedia.org/wiki/Currying currying})
90+
method and tries to infer what should be injected by using function argument names as dependency
91+
identifiers.
9892

9993
**IMPORTANT**
10094
Minifiers/obfuscators change the names of function arguments and will therefore break the `$inject`

docs/content/guide/dev_guide.mvc.understanding_model.ngdoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ only, not recommended for real applications):
3939
Angular creates models implicitly (by creating a scope property and assigning it a suitable value)
4040
when processing the following template constructs:
4141

42-
* Form input, select, and textarea elements:
42+
* Form input, select, textarea and other form elements:
4343

4444
<input name="query" value="fluffy cloud">
4545

docs/content/guide/dev_guide.overview.ngdoc

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,17 @@ easier a web developer's life can if they're using angular:
4343
<doc:example>
4444
<doc:source>
4545
<b>Invoice:</b>
46-
<br/>
47-
<br/>
46+
<br />
47+
<br />
4848
<table>
4949
<tr><td> </td><td> </td>
5050
<tr><td>Quantity</td><td>Cost</td></tr>
5151
<tr>
52-
<td><input name="qty" value="1"
53-
ng:validate="integer:0"
54-
ng:required/></td>
55-
<td><input name="cost" value="19.95"
56-
ng:validate="number"
57-
ng:required/></td>
52+
<td><input name="qty" value="1" ng:validate="integer:0" ng:required /></td>
53+
<td><input name="cost" value="19.95" ng:validate="number" ng:required /></td>
5854
</tr>
5955
</table>
60-
<hr>
56+
<hr />
6157
<b>Total:</b> {{qty * cost | currency}}
6258
</doc:source>
6359
<!--

docs/content/guide/dev_guide.services.testing_services.ngdoc

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,42 @@
44
@description
55

66
Following is a unit test for the service in the example in {@link
7-
dev_guide.services.registering_services Registering Angular Services}. The unit test example uses
8-
Jasmine spy (mock) instead of a real browser alert.
7+
dev_guide.services.creating_services Creating Angular Services}. The unit test example uses Jasmine
8+
spy (mock) instead of a real browser alert.
99

1010
<pre>
1111
var mock, notify;
1212

1313
beforeEach(function() {
14-
mock = {alert: jasmine.createSpy()};
15-
notify = angular.service('notify')(mock);
14+
mock = {alert: jasmine.createSpy()};
15+
notify = angular.service('notify')(mock);
1616
});
1717

1818
it('should not alert first two notifications', function() {
19-
notify('one');
20-
notify('two');
21-
expect(mock.alert).not.toHaveBeenCalled();
19+
notify('one');
20+
notify('two');
21+
22+
expect(mock.alert).not.toHaveBeenCalled();
2223
});
2324

2425
it('should alert all after third notification', function() {
25-
notify('one');
26-
notify('two');
27-
notify('three');
28-
expect(mock.alert).toHaveBeenCalledWith("one\ntwo\nthree");
26+
notify('one');
27+
notify('two');
28+
notify('three');
29+
30+
expect(mock.alert).toHaveBeenCalledWith("one\ntwo\nthree");
2931
});
3032

3133
it('should clear messages after alert', function() {
32-
notify('one');
33-
notify('two');
34-
notify('third');
35-
notify('more');
36-
notify('two');
37-
notify('third');
38-
expect(mock.alert.callCount).toEqual(2);
39-
expect(mock.alert.mostRecentCall.args).toEqual(["more\ntwo\nthird"]);
34+
notify('one');
35+
notify('two');
36+
notify('third');
37+
notify('more');
38+
notify('two');
39+
notify('third');
40+
41+
expect(mock.alert.callCount).toEqual(2);
42+
expect(mock.alert.mostRecentCall.args).toEqual(["more\ntwo\nthird"]);
4043
});
4144
</pre>
4245

0 commit comments

Comments
 (0)