My web site looks like this.
<https://lh6.googleusercontent.com/-EUIf8YgAPhQ/U7bLoljJMPI/AAAAAAAACdw/V0kwLHpAJtU/s1600/site1.png> It has a list of sports players which I can add by clicking on the add button on top. <https://lh4.googleusercontent.com/-n17K3KmX2r4/U7bNWWs8C2I/AAAAAAAACeA/d2vOcyBbPdM/s1600/site3.png> So here I decided to write Babe Ruth. Back on my home page Babe Ruth should be added to my list but he doesn't appear: <https://lh5.googleusercontent.com/-rSfJ8HSeEqY/U7bO9qV8p8I/AAAAAAAACeM/3RCJv9LmFx8/s1600/site1.png> I'm using POSTMAN to check the queries: <https://lh6.googleusercontent.com/-RqQjYsjAGdo/U7bPkd9OpfI/AAAAAAAACeU/tP1E9-VOAF4/s1600/site4.png> and using POSTMAN and its PUT function I can update its name to Babe Ruth: <https://lh4.googleusercontent.com/-KhRNrksS0Tg/U7bQWW1IgmI/AAAAAAAACeg/OUlWtlhITJc/s1600/site5.png> when I click send it says player updated... And now when I go back to my homepage I see his name appears: <https://lh3.googleusercontent.com/-Rg-qtuFl_mc/U7bQ8hje59I/AAAAAAAACeo/pUAelIorZds/s1600/site6.png> My problem is that it doesn't add his name to the list immediately -- although an item gets added to my database. I assume it's some sort of parsing issue but I have no clue what to do. Code: *Template - add.html:* <div class="container"> <div class="panel panel-default"> <div class="panel-heading">Add Sports Player</div> <div class="panel-body"> <form class="form" method="post" ng-submit="addShow()" name="addForm"> <div class="form-group" ng-class="{ 'has-success' : addForm.showName.$valid && addForm.showName.$dirty, 'has-error' : addForm.showName.$invalid && addForm.showName.$dirty }"> <input class="form-control" type="text" name="showName" ng-model="showName" placeholder="Enter sports player name" required autofocus> <div class="help-block text-danger" ng-if="addForm.showName.$dirty" ng-messages="addForm.showName.$error"> <div ng-message="required">Sports player name is required.</div> </div> </div> <button class="btn btn-primary" type="submit" ng-disabled="addForm.$invalid">Add</button> </form> </div> </div> </div> *Controller - add.js:* angular.module('MyApp') .controller('AddCtrl', ['$scope', '$alert', 'Player', function($scope, $alert, Player) { $scope.addShow = function() { Player.save({ showName: $scope.showName }, function() { $scope.showName = ''; $scope.addForm.$setPristine(); $alert({ content: 'Sports player has been added.', placement: 'top-right', type: 'success', duration: 3 }); }, function(response) { $scope.showName = ''; $scope.addForm.$setPristine(); $alert({ content: response.data.message, placement: 'top-right', type: 'danger', duration: 3 }); }); }; }]); *Services - player.js:* angular.module('MyApp') .factory('Player', ['$resource', function($resource) { return $resource('/api/players/:_id'); }]); I think that's all the code you need. I hope someone can help me. Thanks -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
