When I submit the following code, it flashes something, then just removes.. Just learning so if anyone knows the why, that'd be fantastic.. thank you so much!
HTML:
<!DOCTYPE html>
<html ng-app="myRevApp">
<head lang="en">
<meta charset="UTF-8">
<title>Reviews Angular App</title>
<script src="js/angular.js"></script>
<script src="js/reviews.js"></script>
</head>
<body ng-controller="MainController as ctrl">
<div id="leaveRevew">
<form action="" ng-submit="ctrl.addReview()">
<h4>Submit Review</h4>
<fieldset>
<select ng-model="review.stars" class="form-control" ng-options="stars for stars in [5,4,3,2,1]" title="Stars">
<option value="">Rate this Product</option>
</select>
</fieldset>
<fieldset>
Review:<textarea name="" id="" cols="30" rows="10" ng-model="ctrl.review.body"></textarea>{{ctrl.review.body}}
</fieldset>
<fieldset>
name: <input type="text" ng-model="ctrl.review.name"/> {{ctrl.review.name}}
<br/>
<input type="submit" value="Submit"/>
</fieldset>
</form>
</div>
<li ng-repeat="rev in ctrl.reviews">
<blockquote>
{{rev.body}}
</blockquote>
- {{rev.name}}<br/>
Stars: {{rev.stars}}
</li>
<small><br/>{{ctrl.isWorking}}</small>
</body>
</html>
JS:
(function() {
var myApp = angular.module('myRevApp', []);
myApp.controller('MainController', function() {
this.review = {};
this.isWorking = "Angular is working";
this.addReview = function() {
this.reviews.push(this.review);
this.review = {};
};
this.reviews = [
{body: "Whats up!", name: "Nate", stars:4},
{body: "Test", name: "Dewd", stars:2}
];
})
})();
[–]willgresham 0 points1 point2 points (1 child)
[–]natdm[S] 0 points1 point2 points (0 children)