scope - update/refresh angularjs ng-repeat with data from server -
i try buil website pictures.
i can load picture, want have system picture.
my problem have refresh page see picture , increment count.
this controller :
$scope.loadingpics = function (){ $http.get('/api/photos') .success(function(awesomethings) { console.log(awesomethings); $scope.firstname = awesomethings; }) .error(function (err){ $scope.errors.other = err.message; }); }; $scope.upvote = function(index){ $scope.vote = 1; var ref = index; var nom = index.url.substr(30, 40); var num = index.vote + 1; $http.put('api/photos/' + nom, { email: email, vote: num }) .success(function (data) { $scope.firstname = data; $scope.loadingpics(); }) .error(function (err){ $scope.errors.other = err.message; }); };
this view :
<li ng-repeat="image in firstname | orderby: 'firstname'" ng-show="isloggedin()" class="thumbnail" title="image 1" on-last-repeat> <img ng-src="../assets/images/pouce.png" ng-click="upvote(image)" data-toggle="popover" data-content="and here's amazing content. it's engaging. right?" data-placement="right" title="popover title"> </li>
this schema :
var photoschema = new schema({ url: string, firstname: string, email: [string], info: string, vote: number, active: boolean });
thanks :d
instead of storing number of likes in schema, store array of object :
var photoschema = new schema({ url: string, firstname: string, email: [string], info: string, vote: [{ date: date, user: string }], active: boolean });
Comments
Post a Comment