I am trying simulate a review system. How does ng submit pass values over to the controller?
In my controller I have
$scope.reviews = function() {
$scope.rating = 0;
$scope.max = 5;
};
$scope.myTextArea = '';
$scope.saveReview = function(rating, myTextArea) {
console.log(rating);
console.log(myTextArea);
};
In my view, I have:
<form name="reviewForm" class="form-horizontal" ng-submit="saveReview(rating, myTextArea)" novalidate>
<div>
<rating ng-model="rating" max="max" aria-labelledby="'product.title'"></rating>
</div>
<div>This is the rating: {{rating}}</div>
<div class="animate-switch" ng-switch-when=true>
<textarea ng-model="myTextArea" class="form-control" placeholder="Write a short review of the product." title="Review"></textarea>
</div>
<button type="submit" class="btn btn-primary pull-right">Submit Review</button>
</form>
When I submit the form, the saveReview function will be called and printout in the console is 0 and ''. So, none of the values are being saved/passed. Ng-model rating shows 5 stars and if you click on 4 stars, the {{rating}} will display 4.
Any ideas?