Skip to content Skip to sidebar Skip to footer

Load Javascript Files Before Angular.module

I want to create a sort of js library. The user should just include ONE js file and he can use all my functions. I'm using angularjs. In my angular.module, I have several 'Injector

Solution 1:

have you tried to do manual bootstrapping and run your scripts before angular.bootstrap as the following?

angular.element(document).ready(function() {
      // add your script here
      angular.bootstrap(document, ['WDX']);
    });


// OR you could add event listener in your app.js as follows:

function onDocumentReady() {
    // add your script here
    angular.bootstrap(document, ["WDX"]);     
}
document.addEventListener('DOMContentLoaded', onDocumentReady, false);

var app = angular.module('WDX', ['ui.bootstrap', 'ngRoute', 'ng-currency', 'ngSanitize']);

Note: remove ng-app from your DOM when doing manual bootstrapping


Post a Comment for "Load Javascript Files Before Angular.module"