在Angular中从nodejs获取JSON

所以我找不到我的答案。 使用节点我从数据库中得到了一切,并将其输出到文件中。 这是简单的JSON数据,聊天logging。 我可以通过我的浏览器访问它。 看起来像这样:

[{ "id":"1b4f0d8b-4577-493e-adde 68a9a96f647d", "message":"Hi", "name":"NilmeX", "timestamp":"18:11" }, { "id":"4b4f2dc1-7162-484b-98b4-dbdbc751dff4", "message":"Hi2", "name":"NilmeX", "timestamp":"18:11" }] 

等等..

现在我怎样才能得到这个angular度的数据? 我尝试了$http.get但我想我搞砸了一些东西…我是新来的angular和节点,所以如果有人可以解释给我我会很高兴。

 <div ng-app="myApp" ng-controller="myCtrl"> <p ng-repeat="item in myArray">{{item.id}} - {{item.name}}</p> </div> <script> var app = angular.module('myApp', []); app.controller('myCtrl', function($scope, $http) { $http.get("service endpoint from nodejs") .then(function(response) { $scope.myArray = response.data; }); }); </script>