File tree Expand file tree Collapse file tree 2 files changed +19
-9
lines changed Expand file tree Collapse file tree 2 files changed +19
-9
lines changed Original file line number Diff line number Diff line change 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' ,
Original file line number Diff line number Diff 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 >
You can’t perform that action at this time.
0 commit comments