Skip to content

Commit a3549ee

Browse files
Ben Blazelyocombe
authored andcommitted
feat: Added support for specifying the type of a file.
* Use files: [{path: 'path/to/file.x', type: 'type'}] where type is either css, html or js. * Added support for specifying the type of a file using requireJS style syntax. * Updated README.md * Added a test case for loading via these methods.
1 parent 11d8dc0 commit a3549ee

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

src/ocLazyLoad.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
if(debug) {
5454
$log.info(eventName, params);
5555
}
56-
}
56+
};
5757

5858
/**
5959
* Load a js/css file
@@ -105,10 +105,10 @@
105105
loaded = 1;
106106
broadcast('ocLazyLoad.fileLoaded', path);
107107
deferred.resolve();
108-
}
108+
};
109109
el.onerror = function(e) {
110110
deferred.reject(new Error('Unable to load ' + path));
111-
}
111+
};
112112
el.async = params.serie ? 0 : 1;
113113

114114
var insertBeforeElem = anchor.lastChild;
@@ -401,7 +401,7 @@
401401
isLoaded = !!moduleExists(module);
402402
}
403403
return isLoaded;
404-
}
404+
};
405405
if(angular.isString(modulesNames)) {
406406
modulesNames = [modulesNames];
407407
}
@@ -591,7 +591,7 @@
591591

592592
// Create a wrapper promise to watch the promise list and resolve it once everything is done.
593593
return $q.all(promisesList);
594-
}
594+
};
595595

596596
filesLoader(config, localParams).then(function success() {
597597
if(moduleName === null) {
@@ -769,7 +769,7 @@
769769
provider[args[1]].apply(provider, args[2]);
770770
}
771771
}
772-
}
772+
};
773773
if(angular.isFunction(args[2][0])) {
774774
callInvoke(args[2][0]);
775775
} else if(angular.isArray(args[2][0])) {
@@ -850,7 +850,7 @@
850850
newInvoke = true;
851851
regInvokes[moduleName][type].push(invokeName);
852852
broadcast('ocLazyLoad.componentLoaded', [moduleName, type, invokeName]);
853-
}
853+
};
854854
if(angular.isString(invokeList) && regInvokes[moduleName][type].indexOf(invokeList) === -1) {
855855
onInvoke(invokeList);
856856
} else if(angular.isObject(invokeList)) {

tests/unit/specs/ocLazyLoad.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ describe('Module: oc.lazyLoad', function() {
152152
testModuleNoExt = {
153153
name: 'testModuleNoExt',
154154
files: [
155-
{type: 'js', file: lazyLoadUrl + 'testModule.NoExtension'},
155+
{type: 'js', path: lazyLoadUrl + 'testModule.NoExtension'},
156+
lazyLoadUrl + 'test.css',
156157
'css!' + lazyLoadUrl + 'test.NoExtCss',
157158
templateUrl
158159
]

0 commit comments

Comments
 (0)