Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/472.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何获取远程JSON?_Javascript_Angularjs - Fatal编程技术网

Javascript 如何获取远程JSON?

Javascript 如何获取远程JSON?,javascript,angularjs,Javascript,Angularjs,我正在构建一个类固醇应用程序,它使用angular js。它从本地JSON文件中读取数据,而我尝试获取远程JSON。我该怎么做呢?下面是我的“show.js”文件中包含的代码。我试过换衣服 RestangularConfigurer.setBaseUrl('http://localhost/data'); 使用指向我的服务器JSON的url,但这也不起作用 (function () { // Protects views where angular is not l

我正在构建一个类固醇应用程序,它使用angular js。它从本地JSON文件中读取数据,而我尝试获取远程JSON。我该怎么做呢?下面是我的“show.js”文件中包含的代码。我试过换衣服

    RestangularConfigurer.setBaseUrl('http://localhost/data'); 
使用指向我的服务器JSON的url,但这也不起作用

    (function () {

    // Protects views where angular is not loaded from errors
    if (typeof angular == 'undefined') {
        return;
    };


    var module = angular.module('ShowModel', ['restangular']);

    module.factory('ShowRestangular', function (Restangular) {

        return Restangular.withConfig(function (RestangularConfigurer) {

            RestangularConfigurer.setBaseUrl('http://localhost/data');
            RestangularConfigurer.setRequestSuffix('.json');
            RestangularConfigurer.setRestangularFields({
                id: "show_id"
            });

        });

    });


})();

我想知道为什么不使用jquery来实现这个功能?您可以将jquery与angular.js合并使用。不确定AngularJs的实现,但请看一看:看一看和。