forked from wyntau/angular-require
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathangular-require.min.js
8 lines (8 loc) · 1.52 KB
/
angular-require.min.js
1
2
3
4
5
6
7
8
/*!
* angular-require 1.3.0
* use require in angular painless
* License: MIT
* Author: Treri
* Build: Fri Sep 04 2015 10:13:41 GMT+0800 (CST)
**/
!function(){angular.module("ngRequire",[]).provider("$require",function(){var r=function(r){return angular.isString(r)&&(r=[r]),r},e=function(r){return r.substr(0,1).toUpperCase()+r.substr(1)},i=function(i){return i=r(i),["$q","$rootScope",function(r,o){var n=r.defer();return require(i,function(){o.$apply(n.resolve)},function(r){r.requireModules.forEach(function(r){requirejs.undef(r)}),o.$broadcast("requireError",r),o.$broadcast("require"+e(r.requireType),r.requireModules)}),n.promise}]},o=function(i){return i=r(i),["$q","$rootScope","$injector",function(r,o,n){var u=r.defer();return require(i,function(){r.all([].slice.call(arguments).map(n.invoke)).then(u.resolve,u.reject)},function(r){r.requireModules.forEach(function(r){requirejs.undef(r)}),o.$broadcast("requireError",r),o.$broadcast("require"+e(r.requireType),r.requireModules)}),u.promise}]};this.require=i,this.requireJS=i,this.requireCSS=i,this.requireResolve=o,this.$get=angular.noop});var r=angular.module;angular.module=function(){var e=[].slice.call(arguments),i=r.apply(angular,e);return e.length<2||e[1].indexOf("ngRequire")<0?i:i.config(["$controllerProvider","$compileProvider","$filterProvider","$provide",function(r,e,o,n){i.controller=r.register,i.directive=e.directive,i.filter=o.register,i.factory=n.factory,i.service=n.service,i.provider=n.provider,i.value=n.value,i.constant=n.constant,i.decorator=n.decorator}])}}();