Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit edde766

Browse files
Update tutorial
1 parent 73b1a5d commit edde766

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

‎angular-forms-models/app.js‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@
2121
}
2222
});
2323

24+
app.controller("ReviewController", function () {
25+
this.review = {};
26+
27+
this.addReview = function (product) {
28+
product.reviews.push(this.review);
29+
};
30+
});
31+
2432
var products = [
2533
{
2634
name: 'Apple iPad Air 2 Wifi/4G 16G',

‎angular-forms-models/index.html‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,29 +59,31 @@ <h4>Đánh giá</h4>
5959
<cite>- {{review.author}}</cite>
6060
</blockquote>
6161

62-
<blockquote>
63-
<b>{{review.stars}} star(s)</b>
64-
{{review.body}}
65-
<cite>- {{review.author}}</cite>
66-
</blockquote>
62+
<form class="form-horizontal" name="reviewForm"
63+
ng-controller="ReviewController as reviewCtrl"
64+
ng-submit="reviewCtrl.addReview(product)">
65+
<blockquote>
66+
<b>{{reviewCtrl.review.stars}} star(s)</b>
67+
{{reviewCtrl.review.body}}
68+
<cite>- {{reviewCtrl.review.author}}</cite>
69+
</blockquote>
6770

68-
<form class="form-horizontal">
6971
<div class="form-group">
7072
<label class="col-sm-1 control-label">Email</label>
7173
<div class="col-sm-6">
72-
<input ng-model="review.author" type="email" class="form-control" placeholder="Email">
74+
<input ng-model="reviewCtrl.review.author" type="email" class="form-control" placeholder="Email">
7375
</div>
7476
</div>
7577
<div class="form-group">
7678
<label class="col-sm-1 control-label">Review</label>
7779
<div class="col-sm-6">
78-
<textarea ng-model="review.body" class="form-control" rows="3"></textarea>
80+
<textarea ng-model="reviewCtrl.review.body" class="form-control" rows="3"></textarea>
7981
</div>
8082
</div>
8183
<div class="form-group">
8284
<label class="col-sm-1 control-label">Star</label>
8385
<div class="col-sm-6">
84-
<select ng-model="review.stars" class="form-control">
86+
<select ng-model="reviewCtrl.review.stars" class="form-control">
8587
<option value="1">1 star</option>
8688
<option value="2">2 stars</option>
8789
<option value="3">3 stars</option>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /