How can ngresource work with a remote server


  • QA Engineer

    There's a web site written on the angular, using rest api, api gives json, ngresource picks, everything's fine while it's on one server.

    Ngresource is working on ajax, so when attempting to obtain or send data to another server, there will be a mistake in rights. You can use jsonP, but then you'll have to rewrite.

     var resource = $resource(url,
                    {callback: "JSON_CALLBACK"},
                    {
                        get: {method: "JSONP"}
                    }
                );
    

    The whole point is rest api, where the headings post, get, delete, put.

    And the question came when he tried to collect a cordova + ionic mobile application.

    You can cut the access-Control-Allow-Origin on the server.

    <?php header('Access-Control-Allow-Origin: *'); ?>
    

    If anyone knows the right way out, tell me.



  • I've been very helpful in the application ionics for the chromium plate: https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2