File tree 2 files changed +19
-9
lines changed
2 files changed +19
-9
lines changed Original file line number Diff line number Diff line change 21
21
}
22
22
} ) ;
23
23
24
+ app . controller ( "ReviewController" , function ( ) {
25
+ this . review = { } ;
26
+
27
+ this . addReview = function ( product ) {
28
+ product . reviews . push ( this . review ) ;
29
+ } ;
30
+ } ) ;
31
+
24
32
var products = [
25
33
{
26
34
name : 'Apple iPad Air 2 Wifi/4G 16G' ,
Original file line number Diff line number Diff line change @@ -59,29 +59,31 @@ <h4>Đánh giá</h4>
59
59
< cite > - {{review.author}}</ cite >
60
60
</ blockquote >
61
61
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 >
67
70
68
- < form class ="form-horizontal ">
69
71
< div class ="form-group ">
70
72
< label class ="col-sm-1 control-label "> Email</ label >
71
73
< 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 ">
73
75
</ div >
74
76
</ div >
75
77
< div class ="form-group ">
76
78
< label class ="col-sm-1 control-label "> Review</ label >
77
79
< 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 >
79
81
</ div >
80
82
</ div >
81
83
< div class ="form-group ">
82
84
< label class ="col-sm-1 control-label "> Star</ label >
83
85
< div class ="col-sm-6 ">
84
- < select ng-model ="review.stars " class ="form-control ">
86
+ < select ng-model ="reviewCtrl. review.stars " class ="form-control ">
85
87
< option value ="1 "> 1 star</ option >
86
88
< option value ="2 "> 2 stars</ option >
87
89
< option value ="3 "> 3 stars</ option >
You can’t perform that action at this time.
0 commit comments