From 0c03727229818eae4b64740fbf2936c99a0503e7 Mon Sep 17 00:00:00 2001 From: Ben Elliott Date: Thu, 18 Feb 2016 11:32:36 +0000 Subject: [PATCH 1/3] Add support for Angular 1.5 components --- src/angularAMD.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/angularAMD.js b/src/angularAMD.js index 2faa891..e3697dc 100644 --- a/src/angularAMD.js +++ b/src/angularAMD.js @@ -408,6 +408,10 @@ define(function () { compileProvider.directive(name, constructor); return this; }, + component : function(name, constructor) { + compileProvider.component(name, constructor); + return this; + }, filter : function(name, constructor) { filterProvider.register(name, constructor); return this; @@ -498,6 +502,8 @@ define(function () { AngularAMD.prototype.controller = executeProvider('controller'); // .directive AngularAMD.prototype.directive = executeProvider('directive'); + // .component + AngularAMD.prototype.component = executeProvider('component'); // .filter AngularAMD.prototype.filter = executeProvider('filter'); // .factory From 4cfe71e09d581b6bf8be3bd30d304df8e09fb64c Mon Sep 17 00:00:00 2001 From: Ben Elliott Date: Thu, 18 Feb 2016 11:32:36 +0000 Subject: [PATCH 2/3] Add support for Angular 1.5 components --- src/angularAMD.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/angularAMD.js b/src/angularAMD.js index 2faa891..e3697dc 100644 --- a/src/angularAMD.js +++ b/src/angularAMD.js @@ -408,6 +408,10 @@ define(function () { compileProvider.directive(name, constructor); return this; }, + component : function(name, constructor) { + compileProvider.component(name, constructor); + return this; + }, filter : function(name, constructor) { filterProvider.register(name, constructor); return this; @@ -498,6 +502,8 @@ define(function () { AngularAMD.prototype.controller = executeProvider('controller'); // .directive AngularAMD.prototype.directive = executeProvider('directive'); + // .component + AngularAMD.prototype.component = executeProvider('component'); // .filter AngularAMD.prototype.filter = executeProvider('filter'); // .factory From 27065ea6d8b91b3b0de7f0bec7f9ce6cb11c6b11 Mon Sep 17 00:00:00 2001 From: Ben Elliott Date: Fri, 19 Feb 2016 08:57:00 +0000 Subject: [PATCH 3/3] Only alias .component if found on $compileProvider --- src/angularAMD.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/angularAMD.js b/src/angularAMD.js index e3697dc..c888ee8 100644 --- a/src/angularAMD.js +++ b/src/angularAMD.js @@ -394,7 +394,7 @@ define(function () { $provide: provide }; - // Substitue provider methods from app call the cached provider + // Substitute provider methods from app call the cached provider angular.extend(onDemandLoader, { provider : function(name, constructor) { provide.provider(name, constructor); @@ -409,8 +409,7 @@ define(function () { return this; }, component : function(name, constructor) { - compileProvider.component(name, constructor); - return this; + // do nothing by default }, filter : function(name, constructor) { filterProvider.register(name, constructor); @@ -435,6 +434,17 @@ define(function () { }, animation: angular.bind(animateProvider, animateProvider.register) }); + + // Only add component method if present on compileProvider (i.e. Angular >= v.1.5): + if (compileProvider.component) { + angular.extend(onDemandLoader, { + component : function(name, constructor) { + compileProvider.component(name, constructor); + return this; + } + }); + } + angular.extend(alt_app, onDemandLoader); }]