Home >Web Front-end >JS Tutorial >Operation Angularjs cross-domain whitelist setting

Operation Angularjs cross-domain whitelist setting

php中世界最好的语言
php中世界最好的语言Original
2018-06-07 14:52:372080browse

This time I will bring you the cross-domain whitelist settings for Angularjs. What are the precautions for setting up the whitelist cross-domain for Angularjs? The following is a practical case, let’s take a look.

Inject in config$sceDelegateProviderThe service uses the resourceUrlWhitelist([])method to add a whitelist

When crossing domains, set the method attribute to "jsonp" can be accessed

app.config(["$sceDelegateProvider",function($sceDelegateProvider){ 
 
    $sceDelegateProvider.resourceUrlWhitelist([  <span style="white-space:pre;">   </span>//跨域添加白名单 
      "self", 
      "http://datainfo.duapp.com/**" 
    ]); 
  } 
]); 
$http({ 
   method:"JSONP", 
   url:"http://datainfo.duapp.com/shopdata/getGoods.php", 
   params:{classID:$stateParams.classID} 
})

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

Node uses Puppeteer as a crawler

How Angular ng-animate and ng-cookies are used in the project use

The above is the detailed content of Operation Angularjs cross-domain whitelist setting. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn