0.0.4 • Published 8 years ago

angular-cross-domain-request v0.0.4

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

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
            });
        });
});

API

CdrService.init(bridgePath, callback)

CdrService.get(url, params, body, headers, cb){

CdrService.post(url, params, body, headers, cb){