阅读背景:

Angular.js请求的资源上没有“Access-Control-Allow-Origin”标头。因此不允许原点'null'访问

来源:互联网 
//Create an Angular Module.
var newsModule = angular.module('NewsModule', []);

//Create an Angular Controller.
newsModule.controller('newsCtrl', ['$scope', '$http', function ($scope, $http) {
//function retrives POST,UPDATE,DELETE,GET data

$http.defaults.headers.put = {
        'Access-Control-Allow-Origin': '*',
        'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
        'Access-Control-Allow-Headers': 'Content-Type, X-Requested-With'
        };
        $http.defaults.useXDomain = true;

    $scope.throughdata = function (){

 delete $http.defaults.headers.common['X-Requested-With'];
         $http.get('https://www.google.com').then(function(data,error){
            alert(data);
            alert(error);
            $scope.days=data.data;
          });



    }
}
 ]);
//Create an Angular Module.
var newsModule = an



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: