File

projects/app-base-library/src/lib/angular/angular-loader.ts

Index

Methods

Methods

Static load
load(options: )
Parameters :
Name Optional
options no
Returns : any
declare var _: any;
declare var System: any;
declare var Promise: any;

export class AngularLoader {

    /* usage:
    System.config({
          baseURL: 'https://app-base-library.firebaseapp.com/dist',
          packages: {
              'library': {
                  defaultExtension: 'js'
              }
          },
      });
    System.import('angular/angular-loader').then(function(module) {
        module.Loader.load({extension:'.js',exclude:['Server','Permissions']}).then(function(angular){
            console.log(angular);
            // call your applications init function here.
        });
    });
    */

    // todo: loader for use in wordpress / drupal
    static load(options) {
        const namespace = '_abl_angular';
        return new Promise(function(resolve, reject) {
            const abl_angular: any = {};
            let extension = '';
            if (options.extension) {
                extension = options.extension;
            }

            // System.import(options.path + 'classMap' + extension).then(function (mapping) {
            //     const imports = [];
            //     let classPath;
            //     _.each(mapping, function(map){
            //         let exclude = false;
            //         _.each(map, function(v, k){
            //             classPath = v;
            //             if (options.exclude && options.exclude.length) {
            //                 _.each(options.exclude, function(className){
            //                     if (className === k) {
            //                         exclude = true;
            //                     }
            //                 });
            //             }
            //             if (!exclude) {
            //                 imports.push(System.import(options.path + classPath + extension));
            //             }
            //             exclude = false;
            //         });
            //     });
            //     Promise.all(imports).then(function(modules) {
            //         _.each(modules, function(module){
            //             if (module.Base) {
            //                 abl_angular.base = new module.Base;
            //             }
            //         });
            //         _.each(modules, function(module){
            //             _.each(module, function(v, k){
            //                 abl_angular[k] = v;
            //             });
            //         });
            //         if (typeof window !== 'undefined') {
            //             (<any>window)[namespace] = abl_angular;
            //             if (options.namespace) {
            //                 (<any>window)[options.namespace] = abl_angular;
            //             }
            //         }
            //         resolve(abl_angular);
            //     });
            // });

        });
    };

}

results matching ""

    No results matching ""