Skip to content

Commit e0ee3a0

Browse files
vojtajinaIgorMinar
authored andcommitted
Update latest docs content from gdocs
1 parent e670a81 commit e0ee3a0

File tree

8 files changed

+129
-141
lines changed

8 files changed

+129
-141
lines changed

docs/content/cookbook/advancedform.ngdoc

Lines changed: 72 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -9,80 +9,80 @@ detection, and preventing invalid form submission.
99

1010

1111
<doc:example>
12-
<doc:source>
13-
<script>
14-
UserForm.$inject = ['$invalidWidgets'];
15-
function UserForm($invalidWidgets){
16-
this.$invalidWidgets = $invalidWidgets;
17-
this.state = /^\w\w$/;
18-
this.zip = /^\d\d\d\d\d$/;
19-
this.master = {
20-
name: 'John Smith',
21-
address:{
22-
line1: '123 Main St.',
23-
city:'Anytown',
24-
state:'AA',
25-
zip:'12345'
26-
},
27-
contacts:[
28-
{type:'phone', value:'1(234) 555-1212'}
29-
]
30-
};
31-
this.cancel();
32-
}
33-
34-
35-
UserForm.prototype = {
36-
cancel: function(){
37-
this.form = angular.copy(this.master);
38-
},
39-
40-
41-
save: function(){
42-
this.master = this.form;
43-
this.cancel();
44-
}
45-
};
46-
</script>
47-
<div ng:controller="UserForm">
48-
49-
50-
<label>Name:</label><br/>
51-
<input type="text" name="form.name" ng:required/> <br/><br/>
52-
53-
54-
<label>Address:</label><br/>
55-
<input type="text" name="form.address.line1" size="33" ng:required/> <br/>
56-
<input type="text" name="form.address.city" size="12" ng:required/>,
57-
<input type="text" name="form.address.state" size="2" ng:required ng:validate="regexp:state"/>
58-
<input type="text" name="form.address.zip" size="5" ng:required
12+
<doc:source>
13+
<script>
14+
UserForm.$inject = ['$invalidWidgets'];
15+
function UserForm($invalidWidgets){
16+
this.$invalidWidgets = $invalidWidgets;
17+
this.state = /^\w\w$/;
18+
this.zip = /^\d\d\d\d\d$/;
19+
this.master = {
20+
name: 'John Smith',
21+
address:{
22+
line1: '123 Main St.',
23+
city:'Anytown',
24+
state:'AA',
25+
zip:'12345'
26+
},
27+
contacts:[
28+
{type:'phone', value:'1(234) 555-1212'}
29+
]
30+
};
31+
this.cancel();
32+
}
33+
34+
35+
UserForm.prototype = {
36+
cancel: function(){
37+
this.form = angular.copy(this.master);
38+
},
39+
40+
41+
save: function(){
42+
this.master = this.form;
43+
this.cancel();
44+
}
45+
};
46+
</script>
47+
<div ng:controller="UserForm">
48+
49+
50+
<label>Name:</label><br/>
51+
<input type="text" name="form.name" ng:required/> <br/><br/>
52+
53+
54+
<label>Address:</label><br/>
55+
<input type="text" name="form.address.line1" size="33" ng:required/> <br/>
56+
<input type="text" name="form.address.city" size="12" ng:required/>,
57+
<input type="text" name="form.address.state" size="2" ng:required ng:validate="regexp:state"/>
58+
<input type="text" name="form.address.zip" size="5" ng:required
5959
ng:validate="regexp:zip"/><br/><br/>
6060

6161

62-
<label>Phone:</label>
63-
[ <a href="" ng:click="form.contacts.$add()">add</a> ]
64-
<div ng:repeat="contact in form.contacts">
65-
<select name="contact.type">
66-
<option>email</option>
67-
<option>phone</option>
68-
<option>pager</option>
69-
<option>IM</option>
70-
</select>
71-
<input type="text" name="contact.value" ng:required/>
72-
[ <a href="" ng:click="form.contacts.$remove(contact)">X</a> ]
73-
</div>
74-
<button ng:click="cancel()" disabled="{{master.$equals(form)}}">Cancel</button>
75-
<button ng:click="save()" disabled="{{$invalidWidgets.visible() ||
62+
<label>Contacts:</label>
63+
[ <a href="" ng:click="form.contacts.$add()">add</a> ]
64+
<div ng:repeat="contact in form.contacts">
65+
<select name="contact.type">
66+
<option>email</option>
67+
<option>phone</option>
68+
<option>pager</option>
69+
<option>IM</option>
70+
</select>
71+
<input type="text" name="contact.value" ng:required/>
72+
[ <a href="" ng:click="form.contacts.$remove(contact)">X</a> ]
73+
</div>
74+
<button ng:click="cancel()" disabled="{{master.$equals(form)}}">Cancel</button>
75+
<button ng:click="save()" disabled="{{$invalidWidgets.visible() ||
7676
master.$equals(form)}}">Save</button>
7777

7878

79-
<hr/>
80-
Debug View:
81-
<pre>form={{form}}
82-
master={{master}}</pre>
83-
</div>
84-
</doc:source>
85-
<doc:scenario>
79+
<hr/>
80+
Debug View:
81+
<pre>form={{form}}
82+
master={{master}}</pre>
83+
</div>
84+
</doc:source>
85+
<doc:scenario>
8686
it('should enable save button', function(){
8787
expect(element(':button:contains(Save)').attr('disabled')).toBeTruthy();
8888
input('form.name').enter('');
@@ -100,7 +100,7 @@ master.$equals(form)}}">Save</button>
100100
expect(element(':button:contains(Cancel)').attr('disabled')).toBeTruthy();
101101
expect(element(':input[name=form.name]').val()).toEqual('John Smith');
102102
});
103-
</doc:scenario>
103+
</doc:scenario>
104104
</doc:example>
105105

106106

@@ -109,15 +109,10 @@ master.$equals(form)}}">Save</button>
109109
#Things to notice
110110

111111

112-
* Cancel & save buttons are only enabled if the form is dirty -- there is something to cancel or
113-
save.
112+
* Cancel & save buttons are only enabled if the form is dirty there is something to cancel or
113+
save.
114114
* Save button is only enabled if there are no validation errors on the form.
115115
* Cancel reverts the form changes back to original state.
116116
* Save updates the internal model of the form.
117117
* Debug view shows the two models. One presented to the user form and the other being the pristine
118-
copy master.
119-
120-
121-
122-
123-
118+
copy master.

docs/content/cookbook/buzz.ngdoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ to retrieve Buzz activity and comments.
4343
<img src="{{item.actor.thumbnailUrl}}" style="max-height:30px;max-width:30px;"/>
4444
<a href="{{item.actor.profileUrl}}">{{item.actor.name}}</a>
4545
<a href="" ng:click="expandReplies(item)" style="float: right;">
46-
Expand replies: {{item.links.replies.count}}
46+
Expand replies: {{item.links.replies[0].count}}
4747
</a>
4848
</h1>
4949
{{item.object.content | html}}

docs/content/cookbook/form.ngdoc

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,27 +78,19 @@ ng:validate="regexp:zip"/><br/><br/>
7878

7979
it('should validate zip', function(){
8080
expect(using('.example').element(':input[name=user.address.zip]').attr('className'))
81-
.not().toMatch(/ng-validation-error/)
82-
83-
81+
.not().toMatch(/ng-validation-error/);
8482
using('.example').input('user.address.zip').enter('abc');
85-
86-
8783
expect(using('.example').element(':input[name=user.address.zip]').attr('className'))
88-
.toMatch(/ng-validation-error/)
84+
.toMatch(/ng-validation-error/);
8985
});
9086

9187

9288
it('should validate state', function(){
9389
expect(using('.example').element(':input[name=user.address.state]').attr('className'))
94-
.not().toMatch(/ng-validation-error/)
95-
96-
90+
.not().toMatch(/ng-validation-error/);
9791
using('.example').input('user.address.state').enter('XXX');
98-
99-
10092
expect(using('.example').element(':input[name=user.address.state]').attr('className'))
101-
.toMatch(/ng-validation-error/)
93+
.toMatch(/ng-validation-error/);
10294
});
10395
</doc:scenario>
10496
</doc:example>

docs/content/cookbook/mvc.ngdoc

Lines changed: 47 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ no connection between the controller and the view.
1717

1818

1919
<doc:example>
20-
<doc:source>
20+
<doc:source>
2121
<script>
2222
function TicTacToeCntl($location){
2323
this.$location = $location;
@@ -34,8 +34,8 @@ no connection between the controller and the view.
3434
}
3535
TicTacToeCntl.prototype = {
3636
dropPiece: function(row, col) {
37-
if (!this.winner && !this.board) {
38-
this.board = this.nextMove;
37+
if (!this.winner && !this.board[row][col]) {
38+
this.board[row][col] = this.nextMove;
3939
this.nextMove = this.nextMove == 'X' ? 'O' : 'X';
4040
this.setUrl();
4141
}
@@ -51,15 +51,15 @@ no connection between the controller and the view.
5151
this.setUrl();
5252
},
5353
grade: function(){
54-
var b = this.board;
55-
this.winner =
56-
row(0) || row(1) || row(2) ||
57-
col(0) || col(1) || col(2) ||
58-
diagonal(-1) || diagonal(1);
59-
function row(r) { return same(b, b, b);}
60-
function col(c) { return same(b, b, b);}
61-
function diagonal(i) { return same(b[1-i], b, b[1+i]);}
62-
function same(a, b, c) { return (a==b && b==c) ? a : '';};
54+
var b = this.board;
55+
this.winner =
56+
row(0) || row(1) || row(2) ||
57+
col(0) || col(1) || col(2) ||
58+
diagonal(-1) || diagonal(1);
59+
function row(row) { return same(b[row][0], b[row][1], b[row][2]);}
60+
function col(col) { return same(b[0][col], b[1][col], b[2][col]);}
61+
function diagonal(i) { return same(b[0][1-i], b[1][1], b[2][1+i]);}
62+
function same(a, b, c) { return (a==b && b==c) ? a : '';};
6363
},
6464
setUrl: function(){
6565
var rows = [];
@@ -68,12 +68,12 @@ no connection between the controller and the view.
6868
});
6969
this.$location.hashSearch.board = rows.join(';') + '/' + this.nextMove;
7070
},
71-
readUrl: function(scope, value) {
71+
readUrl: function(value) {
7272
if (value) {
7373
value = value.split('/');
74-
this.nextMove = value;
75-
angular.forEach(value.split(';'), function(row, i){
76-
this.board = row.split(',');
74+
this.nextMove = value[1];
75+
angular.forEach(value[0].split(';'), function(row, col){
76+
this.board[col] = row.split(',');
7777
}, this);
7878
this.grade();
7979
} else {
@@ -82,36 +82,38 @@ no connection between the controller and the view.
8282
}
8383
};
8484
</script>
85+
86+
8587
<h3>Tic-Tac-Toe</h3>
8688
<div ng:controller="TicTacToeCntl">
8789
Next Player: {{nextMove}}
8890
<div class="winner" ng:show="winner">Player {{winner}} has won!</div>
89-
<table class="board">
90-
<tr ng:repeat="row in board" style="height:15px;">
91-
<td ng:repeat="cell in row" ng:style="cellStyle"
92-
ng:click="dropPiece($parent.$index, $index)">{{cell}}</td>
93-
</tr>
94-
</table>
95-
<button ng:click="reset()">reset board</button>
91+
<table class="board">
92+
<tr ng:repeat="row in board" style="height:15px;">
93+
<td ng:repeat="cell in row" ng:style="cellStyle"
94+
ng:click="dropPiece($parent.$index, $index)">{{cell}}</td>
95+
</tr>
96+
</table>
97+
<button ng:click="reset()">reset board</button>
9698
</div>
97-
</doc:source>
98-
<doc:scenario>
99-
it('should play a game', function(){
100-
piece(1, 1);
101-
expect(binding('nextMove')).toEqual('O');
102-
piece(3, 1);
103-
expect(binding('nextMove')).toEqual('X');
104-
piece(1, 2);
105-
piece(3, 2);
106-
piece(1, 3);
107-
expect(element('.winner').text()).toEqual('Player X has won!');
108-
});
109-
110-
111-
function piece(row, col) {
112-
element('.board tr:nth-child('+row+') td:nth-child('+col+')').click();
113-
}
114-
</doc:scenario>
99+
</doc:source>
100+
<doc:scenario>
101+
it('should play a game', function(){
102+
piece(1, 1);
103+
expect(binding('nextMove')).toEqual('O');
104+
piece(3, 1);
105+
expect(binding('nextMove')).toEqual('X');
106+
piece(1, 2);
107+
piece(3, 2);
108+
piece(1, 3);
109+
expect(element('.winner').text()).toEqual('Player X has won!');
110+
});
111+
112+
113+
function piece(row, col) {
114+
element('.board tr:nth-child('+row+') td:nth-child('+col+')').click();
115+
}
116+
</doc:scenario>
115117
</doc:example>
116118

117119

@@ -123,13 +125,12 @@ no connection between the controller and the view.
123125
* The controller is defined in JavaScript and has no reference to the rendering logic.
124126
* The controller is instantiated by <angular/> and injected into the view.
125127
* The controller can be instantiated in isolation (without a view) and the code will still execute.
126-
This makes it very testable.
128+
This makes it very testable.
127129
* The HTML view is a projection of the model. In the above example, the model is stored in the
128-
board variable.
130+
board variable.
129131
* All of the controller's properties (such as board and nextMove) are available to the view.
130132
* Changing the model changes the view.
131133
* The view can call any controller function.
132134
* In this example, the `setUrl()` and `readUrl()` functions copy the game state to/from the URL's
133-
hash so the browser's back button will undo game steps. See deep-linking. This example calls
134-
{@link api/angular.scope.$watch $watch()} to set up a listener that invokes `readUrl()` when
135-
needed.
135+
hash so the browser's back button will undo game steps. See deep-linking. This example calls {@link
136+
api/angular.scope.$watch $watch()} to set up a listener that invokes `readUrl()` when needed.

docs/content/tutorial/step_04.ngdoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ The unit test now verifies that the default ordering property is set.
180180

181181

182182
We used Jasmine's API to extract the controller construction into a `beforeEach` block, which is
183-
shared by all tests in the nearest `describe` block.
183+
shared by all tests in the parent `describe` block.
184184

185185

186186
To run the unit tests, once again execute the `./scripts/test.sh` script and you should see the
@@ -205,7 +205,7 @@ __`test/e2e/scenarios.js`:__
205205
function() {
206206

207207

208-
// let's narrow the dataset to make the test assertions shorter
208+
// narrow the dataset to make the test assertions shorter
209209
input('query').enter('tablet');
210210

211211

docs/content/tutorial/step_08.ngdoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ our model into the view.
111111

112112
__`app/partials/phone-details.html`:__
113113
<pre>
114-
<img ng:src="{{phone.images}}" class="phone"/>
114+
<img ng:src="{{phone.images[0]}}" class="phone"/>
115115

116116

117117
<h1>{{phone.name}}</h1>

docs/content/tutorial/step_10.ngdoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function PhoneDetailCtrl($xhr) {
4242

4343
$xhr('GET', 'phones/' + self.params.phoneId + '.json', function(code, response) {
4444
self.phone = response;
45-
self.mainImageUrl = response.images;
45+
self.mainImageUrl = response.images[0];
4646
});
4747

4848

0 commit comments

Comments
 (0)