npm.io
1.0.2 • Published 10 years ago

ng-api-handler

Licence
ISC
Version
1.0.2
Deps
2
Vulns
10
Weekly
0

ngApiHandler

An AngularJS module for use all Google Apis and your Google Cloud Endpoints (Google App Engine) Using angular gapi , For Encapsulation.

Requirements

Installation

Add library

This module is available as bower package, install it with this command:

bower install ng-api-handler

and it's available too as npm package, install it with this command:

npm install ng-api-handler

or you may download the latest release

Include library
<script type="text/javascript" src="/ng-api-handler/dist/angular-google-gapi.min.js"></script>
Add dependency
var app = angular.module('myModule', ['ngApiHandler']);

Configuration

without Google Auth

add run in root module

app.run(['ApiHandler',
  function(ApiHandler) {
   ApiHandler.connectApi('myApiName','v1');//calling this for access to get all method from the myApiName class api
     }
          ]);

Use

Execute our api
app.controller('myController', ['$scope', 'ApiHandler',
    function myController($scope, ApiHandler) {
    param={};//or {item:value[,item1:value1]}
      	ApiHandler.callService('myApiName', 'you.api.method.name',param}).then( function(resp) {
               //success
                console.info(resp);
	}, function(err) {
	//failure
		console.error(err);
	});
    }
]);

Keywords