0.2.0 • Published 5 years ago

@authllizer/ng v0.2.0

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

AngularJs Authllizer Module

Source Code Version MIT License Bundle Size TypeScript

This module is a wrapper of Authllizer for comfortable using it in AngularJs.

Example

There are AngularJs example project in the source code.

Install

$ npm install --save @authllizer/ng
# and install peer dependencies 
$ npm install --save @authllizer/core

Setup

import * as angular from 'angular';
import { default as AuthllizerModule } from '@authllizer/ng';
let appModule = angular.module('myApp', [ AuthllizerModule ]);

or

let appModule = angular.module('myApp',[ 'authllizer' ]);

Config

    import { IAuthllizerOptions } from '@authllizer/core';
    import { AuthProvider } from '@authllizer/ng';

    appModule.config(['$authProvider', ($authProvider: AuthProvider)=>{
        $authProvider.config({
            // ...
        } as IAuthllizerOptions);
    });

Note: Authllizer auto config to use $http as HttpClient. authllizer required global es6 Promise, You can use AngularJs $q service ($window.Promise = $q;)

Use

    import { Authllizer } from '@authllizer/core';

    class SomeController{
        
        static $inject: string[] = ['$auth'];

        private $auth: Authllizer;

        constructor($auth: Authllizer){
            this.$auth = $auth;
        }
    }

    appModule.component('SomeComponent', { controller: SomeController, ... });

anther

    import { Authllizer } from '@authllizer/core';

    appModule.controller('SomeController', [ '$auth', function($auth: Authllizer) {

    }]);

Interceptor

    import { IHttpProvider } from 'angular';

    appModule.config(['$httpProvider', ($httpProvider: IHttpProvider)=>{
        $httpProvider.interceptors.push('tokenInterceptor');
    });

License

Copyright © 2017 Yisrael Eliav, Licensed under the MIT license.