|
1 | | -/*! |
2 | | - angularAMD v0.2.1 |
| 1 | +/* |
| 2 | + angularAMD v<%= cvars.proj_version %> |
3 | 3 | (c) 2013-2014 Marcos Lin https://github.com/marcoslin/ |
4 | 4 | License: MIT |
5 | 5 | */ |
| 6 | + |
6 | 7 | define(function () { |
7 | 8 | 'use strict'; |
8 | 9 | var bootstrapped = false, |
@@ -95,6 +96,11 @@ define(function () { |
95 | 96 | }; |
96 | 97 |
|
97 | 98 | window.angular = alt_angular; |
| 99 | + |
| 100 | + if (require.defined('angular')) { |
| 101 | + require.undef('angular'); |
| 102 | + define('angular', [], alt_angular); |
| 103 | + } |
98 | 104 | } |
99 | 105 |
|
100 | 106 | // Constructor |
@@ -189,15 +195,16 @@ define(function () { |
189 | 195 | if (typeof alt_angular === 'undefined') { |
190 | 196 | throw new Error('Alternate angular not set. Make sure that `enable_ngload` option has been set when calling angularAMD.bootstrap'); |
191 | 197 | } |
192 | | - |
| 198 | + |
193 | 199 | // Process alternate queue in FIFO fashion |
194 | 200 | function processRunBlock(block) { |
195 | 201 | //console.info('"' + item.name + '": executing run block: ', run_block); |
196 | 202 | run_injector.invoke(block); |
197 | 203 | } |
198 | 204 |
|
199 | | - while (alternate_queue.length) { |
200 | | - var item = alternate_queue.shift(), |
| 205 | + // Process the config blocks |
| 206 | + for (var i=0;i<alternate_queue.length;i++) { |
| 207 | + var item = alternate_queue[i], |
201 | 208 | invokeQueue = item.module._invokeQueue, |
202 | 209 | y; |
203 | 210 |
|
@@ -245,18 +252,22 @@ define(function () { |
245 | 252 | } |
246 | 253 |
|
247 | 254 |
|
248 | | - // Execute the run block of the module |
| 255 | + } |
| 256 | + |
| 257 | + //after we have executed all config blocks, we finally execute the run blocks |
| 258 | + while (alternate_queue.length) { |
| 259 | + var item = alternate_queue.shift(); |
249 | 260 | if (item.module._runBlocks) { |
250 | 261 | angular.forEach(item.module._runBlocks, processRunBlock); |
251 | 262 | } |
252 | | - |
253 | | - /* |
254 | | - Clear the cached modules created by alt_angular so that subsequent call to |
255 | | - angular.module will return undefined. |
256 | | - */ |
257 | | - alternate_modules = {}; |
258 | 263 | } |
259 | 264 |
|
| 265 | + /* |
| 266 | + Clear the cached modules created by alt_angular so that subsequent call to |
| 267 | + angular.module will return undefined. |
| 268 | + */ |
| 269 | + alternate_modules = {}; |
| 270 | + |
260 | 271 | }; |
261 | 272 |
|
262 | 273 |
|
@@ -317,6 +328,10 @@ define(function () { |
317 | 328 |
|
318 | 329 | // Restore original angular instance |
319 | 330 | window.angular = orig_angular; |
| 331 | + if (require.defined('angular')) { |
| 332 | + require.undef('angular'); |
| 333 | + define('angular', [], orig_angular); |
| 334 | + } |
320 | 335 |
|
321 | 336 | // Clear stored app |
322 | 337 | orig_app = undefined; |
@@ -414,6 +429,10 @@ define(function () { |
414 | 429 | provide.value(name, constructor); |
415 | 430 | return this; |
416 | 431 | }, |
| 432 | + component : function(name, constructor) { |
| 433 | + compileProvider.component(name, constructor); |
| 434 | + return this; |
| 435 | + }, |
417 | 436 | animation: angular.bind(animateProvider, animateProvider.register) |
418 | 437 | }); |
419 | 438 | angular.extend(alt_app, onDemandLoader); |
@@ -495,6 +514,8 @@ define(function () { |
495 | 514 | AngularAMD.prototype.value = executeProvider('value'); |
496 | 515 | // .animation |
497 | 516 | AngularAMD.prototype.animation = executeProvider('animation'); |
| 517 | + // .component |
| 518 | + AngularAMD.prototype.component = executeProvider('component'); |
498 | 519 |
|
499 | 520 | // Create a new instance and return |
500 | 521 | return new AngularAMD(); |
|
0 commit comments