Quick start

I want to start like right now!

  1. Download ocLazyLoad.js. It can be found in the 'dist' folder of the git repository. You can also install it with bower install oclazyload or npm install oclazyload.

  2. Add the module oc.lazyLoad to your application:

var myApp = angular.module("MyApp", ["oc.lazyLoad"]);
  1. Load on demand:
myApp.controller("MyCtrl", function($ocLazyLoad) {
    $ocLazyLoad.load('testModule.js');
});

With $ocLazyLoad you can load angular modules, but if you want to load any component (controllers / services / filters / ...) without defining a new module it's entirely possible (just make sure that you define this component within an existing module).

There are multiple ways to use $ocLazyLoad to load your files, just choose the one that you prefer.

Also don't forget that if you want to get started and the docs are not enough, see the examples in the 'examples' folder!


Did this page help you?