angular-cross-domain-request
v0.0.4
Published
An angular.js service for making cross-domain requests using iframe and post message API
Downloads
6
Maintainers
Readme
angular-http-cross-domain-request
Install
npm install angular-http-cross-domain-request
copy this files to your server's static files location:
$/tests/bridge_stub/bridge.html $/tests/bridge_stub/connect.utils.js $/tests/bridge_stub/connect.bridge.js
for example:
- TOMCAT Server - put these files in WEB-INF folder
- Express Server - put these files where js, html, css files are
Usage
angular
.module('myAppModule', [cdr])
.controller('MyAppController', MyAppController);
MyAppController.$inject = ['$scope', 'CdrService'];
function MyAppController($scope, CdrService){
var bridgeUrl = 'http://localhost:8081/bridge.html';
var apiUrl = 'http://localhost:8081/myApiFunction'
CdrService.init(bridgeUrl, function(iframe){
var urlParams = []
bodyData = null,
headers = {'Content-Type':'application/json', 'test': 'test'};
CdrService.get(apiUrl, urlParams, bodyData, headers, function(err, data){
if (err) //handle error
//handle response
});
});
});