Angular get JSON data with ajax

前端 未结 1 779
独厮守ぢ
独厮守ぢ 2021-01-20 04:42

How can I get json data via ajax with angular? I tried a lot but my code is not working. My code:




        
相关标签:
1条回答
  • 2021-01-20 05:34

    Did you try like this..

    <script>
            var app = angular.module('test', [])
            app.controller('TestCtrl', function ($scope, $http) {
                $http.get("http://jsonplaceholder.typicode.com/users").then(function(res,status,xhr) {
                    $scope.data = res.data;
                });
            });
        </script>
    
    0 讨论(0)
提交回复
热议问题