lmc-eu / ngx-library

[INACTIVE] Extension library for AngularJS projects
MIT License
72 stars 20 forks source link

NGX doesn't support concatenating with other js files #42

Closed rokerkony closed 9 years ago

rokerkony commented 11 years ago

NGX takes its basePath from <script> tag https://github.com/lmc-eu/ngx-library/blob/master/src/modules/config/config.js#L10

Can be solved with some configuration like

<ngx-path value="path/to/ngx/" />
<script src="concatFile.js" ... /> <!-- ngx with other files-->

than:

    // try if base path is injected through ngx-path element
    var ngxPathElement = document.getElementsByTagName('ngx-path')[0];
    if (angular.isElement(ngxPathElement)) {
        basePath = ngxPathElement.getAttribute('value');
    } else {
        angular.forEach(document.getElementsByTagName('script'), function(script) {
            if (script.src.match(re)) {
                basePath = script.src.replace(re, '');
            }
        });
    }

    if (basePath === null) {
        throw new Error('ngx base path cannot be determined.');
    }
pdanis commented 11 years ago

This "basePath" thing is used for loading external dependencies used by ngx modules and should be refactored in general using bower, config etc.. But as temporary fix I think this is acceptable, but I would just use data-ngx-basepath in script tag .. <script src="concatFile.js" data-ngx-basepath="path/to/ngx"></script>