Angularjs – Displaying data using $ http from remote server

i want to send a http get request which is not a problem. But the problem is i want to disply the data from the server page. Does it has to be a JSON page to display the data from remote server ? or any sort of data can be displayed ? if yes , then how Thank you

Enter URL :

  • {{post}}

var app = angular.module('myApp', []); app.controller('myCtrl', function($scope, $http) { $scope.callAPI = function() { // 2 //console.log($scope.url); //3 $http.get($scope.url) .success(function(response) { $scope.posts = response.data; //4 }); }; });

another version of code

Enter URL :

var app = angular.module('myApp', []); app.controller('myCtrl', function($scope, $http) { $scope.$watch('url', function() { fetch(); }); function fetch() { console.log($scope.url); $http.get($scope.url) .success(function(response) { $scope.result = response.data; }); } $scope.callAPI= function() { this.setSelectionRange(0, this.value.length); } });

hey i have found my answer of my question … there was a mistake in the source code here is the right one

Enter URL :

  • {{data}}

and

            var app = angular.module('myApp', []);
                app.controller('myCtrl', function($scope, $http) {
                    $scope.clickButton = function() {
                        console.log($scope.url);
                        $http.get($scope.url)
                            .then(function(response) {
                             $scope.result = response.data;
                                });
                             };

                        });

    

:)

if anyone has a similer problem , i hope this answer will help .. cheers

Hello, buddy!稿源:Hello, buddy! (源链) | 关于 | 阅读提示

本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 前端开发 » Angularjs – Displaying data using $ http from remote server

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录