Angularjs, Factory, Do Post Then Get Method
i'm having a little problems when doing REST requests with AngularJS. I have server part done in PHP(Laravel), I tested it with POSTMAN and it's working fine. I just have POST /exp
Solution 1:
Your $scope.results object is defined as having two properties, but when you iterate it in an ng-repeat, you try to access properties of strings that don't exist, so it fails silently.
// your results object:$scope.results = postExpressionFactory.evaluate({'expression':$scope.expression});
// so your object looks like this:
{
expression: something,
result: somethingElse,
}
The way you attempt to access it:
<divclass="list-group"ng-repeat="res in results"><aclass="list-group-item"><h4class="list-group-item-heading">{{res.expression}}</h4><h4class="list-group-item-heading">{{res.result}}</h4></a></div>
See error in HTML here by printing your object:
<div class="list-group" ng-repeat="res in results">
{{ result }}
<a class="list-group-item">
<h4class="list-group-item-heading">{{res.expression}}</h4><h4class="list-group-item-heading">{{res.result}}</h4>
</a>
</div>
// what you probably want is an array for the results, then push onto the array
$scope.results = [];
// push
$scope.results.push(postExpressionFactory.evaluate({'expression':$scope.expression}));
Post a Comment for "Angularjs, Factory, Do Post Then Get Method"