javascript - AngularJS make REST call and display result in browser -
i'm trying info rest service , display elements in browser. piece of code:
server.prototype.typenames = function() { var json = '{' + '"query" : "match n homecoming n.typename limit 10"' + '}'; $http.post("http://localhost:7474/db/data/cypher", json).then(function(response) { var info = response.data; console.log(data); homecoming data; }); }
i'm sure json , rest phone call right because can see info in console , it's right can't see on page. have in js file:
$scope.typenames = server.typenames()
in html:
{{typenames}}
also: install angularjs debug extension chrome , there it's null:
typenames: null
here (http://pastebin.com/ithv97da) can find bigger part of code. code not mine, server.prototype things there. added server.prototype.typenames , i'm trying work.
your typenames
function isn't returning anything.
depending on version can seek returning whole $http part, improve way homecoming promise, , have promise resolved within .then
callback.
something this:
var deferred = $q.defer(); $http.post("http://localhost:7474/db/data/cypher", json).then(function(response) { var info = response.data; console.log(data); deferred.resolve(data); // <--- key homecoming data; }); homecoming deferred.promise;
javascript angularjs rest
No comments:
Post a Comment