@angular/upgrade 2.0.0-rc.1 → 2.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{upgrade.umd.js → bundles/upgrade.umd.js} +161 -141
- package/bundles/upgrade.umd.min.js +1 -0
- package/esm/index.js.map +1 -1
- package/esm/src/angular_js.d.ts +1 -0
- package/esm/src/angular_js.js.map +1 -1
- package/esm/src/angular_js.metadata.json +1 -1
- package/esm/src/constants.js +1 -1
- package/esm/src/constants.js.map +1 -1
- package/esm/src/constants.metadata.json +1 -1
- package/esm/src/downgrade_ng2_adapter.d.ts +3 -5
- package/esm/src/downgrade_ng2_adapter.js +9 -9
- package/esm/src/downgrade_ng2_adapter.js.map +1 -1
- package/esm/src/metadata.js +1 -1
- package/esm/src/metadata.js.map +1 -1
- package/esm/src/upgrade_adapter.d.ts +1 -8
- package/esm/src/upgrade_adapter.js +56 -48
- package/esm/src/upgrade_adapter.js.map +1 -1
- package/esm/src/upgrade_ng1_adapter.js +39 -27
- package/esm/src/upgrade_ng1_adapter.js.map +1 -1
- package/esm/src/util.js.map +1 -1
- package/esm/src/util.metadata.json +1 -0
- package/esm/upgrade.js +4 -4
- package/esm/upgrade.js.map +1 -1
- package/index.js.map +1 -1
- package/package.json +8 -4
- package/src/angular_js.d.ts +1 -0
- package/src/angular_js.js.map +1 -1
- package/src/angular_js.metadata.json +1 -1
- package/src/constants.js +1 -1
- package/src/constants.js.map +1 -1
- package/src/constants.metadata.json +1 -1
- package/src/downgrade_ng2_adapter.d.ts +3 -5
- package/src/downgrade_ng2_adapter.js +18 -14
- package/src/downgrade_ng2_adapter.js.map +1 -1
- package/src/metadata.js +1 -1
- package/src/metadata.js.map +1 -1
- package/src/upgrade_adapter.d.ts +1 -8
- package/src/upgrade_adapter.js +58 -46
- package/src/upgrade_adapter.js.map +1 -1
- package/src/upgrade_ng1_adapter.js +40 -26
- package/src/upgrade_ng1_adapter.js.map +1 -1
- package/src/util.js.map +1 -1
- package/src/util.metadata.json +1 -0
- package/upgrade.js +4 -4
- package/upgrade.js.map +1 -1
package/src/upgrade_adapter.d.ts
CHANGED
|
@@ -70,10 +70,6 @@ import * as angular from './angular_js';
|
|
|
70
70
|
* ```
|
|
71
71
|
*/
|
|
72
72
|
export declare class UpgradeAdapter {
|
|
73
|
-
private idPrefix;
|
|
74
|
-
private upgradedComponents;
|
|
75
|
-
private downgradedComponents;
|
|
76
|
-
private providers;
|
|
77
73
|
/**
|
|
78
74
|
* Allows Angular v2 Component to be used from AngularJS v1.
|
|
79
75
|
*
|
|
@@ -273,7 +269,7 @@ export declare class UpgradeAdapter {
|
|
|
273
269
|
* adapter.bootstrap(document.body, ['myExample']);
|
|
274
270
|
*```
|
|
275
271
|
*/
|
|
276
|
-
addProvider(provider: Type | Provider | any[]): void;
|
|
272
|
+
addProvider(provider: Type | Provider | any[] | any): void;
|
|
277
273
|
/**
|
|
278
274
|
* Allows AngularJS v1 service to be accessible from Angular v2.
|
|
279
275
|
*
|
|
@@ -332,18 +328,15 @@ export declare class UpgradeAdapter {
|
|
|
332
328
|
* ```
|
|
333
329
|
*/
|
|
334
330
|
downgradeNg2Provider(token: any): Function;
|
|
335
|
-
private compileNg2Components(compiler, componentFactoryRefMap);
|
|
336
331
|
}
|
|
337
332
|
/**
|
|
338
333
|
* Use `UgradeAdapterRef` to control a hybrid AngularJS v1 / Angular v2 application.
|
|
339
334
|
*/
|
|
340
335
|
export declare class UpgradeAdapterRef {
|
|
341
|
-
private _readyFn;
|
|
342
336
|
ng1RootScope: angular.IRootScopeService;
|
|
343
337
|
ng1Injector: angular.IInjectorService;
|
|
344
338
|
ng2ApplicationRef: ApplicationRef;
|
|
345
339
|
ng2Injector: Injector;
|
|
346
|
-
private _bootstrapDone(applicationRef, ng1Injector);
|
|
347
340
|
/**
|
|
348
341
|
* Register a callback function which is notified upon successful hybrid AngularJS v1 / Angular v2
|
|
349
342
|
* application has been bootstrapped.
|
package/src/upgrade_adapter.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var core_1 = require('@angular/core');
|
|
3
|
-
var platform_browser_dynamic_1 = require('@angular/platform-browser-dynamic');
|
|
4
3
|
var platform_browser_1 = require('@angular/platform-browser');
|
|
5
|
-
var
|
|
6
|
-
var
|
|
4
|
+
var platform_browser_dynamic_1 = require('@angular/platform-browser-dynamic');
|
|
5
|
+
var angular = require('./angular_js');
|
|
7
6
|
var constants_1 = require('./constants');
|
|
8
7
|
var downgrade_ng2_adapter_1 = require('./downgrade_ng2_adapter');
|
|
8
|
+
var metadata_1 = require('./metadata');
|
|
9
9
|
var upgrade_ng1_adapter_1 = require('./upgrade_ng1_adapter');
|
|
10
|
-
var
|
|
10
|
+
var util_1 = require('./util');
|
|
11
11
|
var upgradeCount = 0;
|
|
12
12
|
/**
|
|
13
13
|
* Use `UpgradeAdapter` to allow AngularJS v1 and Angular v2 to coexist in a single application.
|
|
@@ -267,10 +267,11 @@ var UpgradeAdapter = (function () {
|
|
|
267
267
|
var upgrade = new UpgradeAdapterRef();
|
|
268
268
|
var ng1Injector = null;
|
|
269
269
|
var platformRef = platform_browser_1.browserPlatform();
|
|
270
|
-
var applicationRef = core_1.ReflectiveInjector
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
270
|
+
var applicationRef = core_1.ReflectiveInjector
|
|
271
|
+
.resolveAndCreate([
|
|
272
|
+
platform_browser_1.BROWSER_APP_PROVIDERS, platform_browser_dynamic_1.BROWSER_APP_COMPILER_PROVIDERS,
|
|
273
|
+
{ provide: constants_1.NG1_INJECTOR, useFactory: function () { return ng1Injector; } },
|
|
274
|
+
{ provide: constants_1.NG1_COMPILE, useFactory: function () { return ng1Injector.get(constants_1.NG1_COMPILE); } },
|
|
274
275
|
this.providers
|
|
275
276
|
], platformRef.injector)
|
|
276
277
|
.get(core_1.ApplicationRef);
|
|
@@ -290,52 +291,59 @@ var UpgradeAdapter = (function () {
|
|
|
290
291
|
.value(constants_1.NG2_COMPILER, compiler)
|
|
291
292
|
.value(constants_1.NG2_COMPONENT_FACTORY_REF_MAP, componentFactoryRefMap)
|
|
292
293
|
.config([
|
|
293
|
-
'$provide',
|
|
294
|
-
function (provide) {
|
|
294
|
+
'$provide', '$injector',
|
|
295
|
+
function (provide /** TODO #???? */, ng1Injector /** TODO #???? */) {
|
|
295
296
|
provide.decorator(constants_1.NG1_ROOT_SCOPE, [
|
|
296
297
|
'$delegate',
|
|
297
298
|
function (rootScopeDelegate) {
|
|
298
299
|
rootScopePrototype = rootScopeDelegate.constructor.prototype;
|
|
299
300
|
if (rootScopePrototype.hasOwnProperty('$apply')) {
|
|
300
301
|
original$applyFn = rootScopePrototype.$apply;
|
|
301
|
-
rootScopePrototype.$apply = function (exp
|
|
302
|
+
rootScopePrototype.$apply = function (exp /** TODO #???? */) {
|
|
303
|
+
return delayApplyExps.push(exp);
|
|
304
|
+
};
|
|
302
305
|
}
|
|
303
306
|
else {
|
|
304
|
-
throw new Error(
|
|
307
|
+
throw new Error('Failed to find \'$apply\' on \'$rootScope\'!');
|
|
305
308
|
}
|
|
306
309
|
return rootScope = rootScopeDelegate;
|
|
307
310
|
}
|
|
308
311
|
]);
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
var
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
312
|
+
if (ng1Injector.has(constants_1.NG1_TESTABILITY)) {
|
|
313
|
+
provide.decorator(constants_1.NG1_TESTABILITY, [
|
|
314
|
+
'$delegate',
|
|
315
|
+
function (testabilityDelegate) {
|
|
316
|
+
var _this = this;
|
|
317
|
+
var ng2Testability = injector.get(core_1.Testability);
|
|
318
|
+
var origonalWhenStable = testabilityDelegate.whenStable;
|
|
319
|
+
var newWhenStable = function (callback) {
|
|
320
|
+
var whenStableContext = _this;
|
|
321
|
+
origonalWhenStable.call(_this, function () {
|
|
322
|
+
if (ng2Testability.isStable()) {
|
|
323
|
+
callback.apply(this, arguments);
|
|
324
|
+
}
|
|
325
|
+
else {
|
|
326
|
+
ng2Testability.whenStable(newWhenStable.bind(whenStableContext, callback));
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
};
|
|
330
|
+
testabilityDelegate.whenStable = newWhenStable;
|
|
331
|
+
return testabilityDelegate;
|
|
332
|
+
}
|
|
333
|
+
]);
|
|
334
|
+
}
|
|
330
335
|
}
|
|
331
336
|
]);
|
|
332
337
|
ng1compilePromise = new Promise(function (resolve, reject) {
|
|
333
338
|
ng1Module.run([
|
|
334
|
-
'$injector',
|
|
335
|
-
'$rootScope',
|
|
339
|
+
'$injector', '$rootScope',
|
|
336
340
|
function (injector, rootScope) {
|
|
337
341
|
ng1Injector = injector;
|
|
338
|
-
ngZone.onMicrotaskEmpty.subscribe({
|
|
342
|
+
ngZone.onMicrotaskEmpty.subscribe({
|
|
343
|
+
next: function (_ /** TODO #???? */) {
|
|
344
|
+
return ngZone.runOutsideAngular(function () { return rootScope.$evalAsync(); });
|
|
345
|
+
}
|
|
346
|
+
});
|
|
339
347
|
upgrade_ng1_adapter_1.UpgradeNg1ComponentAdapterBuilder.resolve(_this.downgradedComponents, injector)
|
|
340
348
|
.then(resolve, reject);
|
|
341
349
|
}
|
|
@@ -359,9 +367,9 @@ var UpgradeAdapter = (function () {
|
|
|
359
367
|
resolve();
|
|
360
368
|
}
|
|
361
369
|
});
|
|
362
|
-
Promise
|
|
363
|
-
|
|
364
|
-
ng1BootstrapPromise,
|
|
370
|
+
Promise
|
|
371
|
+
.all([
|
|
372
|
+
this.compileNg2Components(compiler, componentFactoryRefMap), ng1BootstrapPromise,
|
|
365
373
|
ng1compilePromise
|
|
366
374
|
])
|
|
367
375
|
.then(function () {
|
|
@@ -449,10 +457,11 @@ var UpgradeAdapter = (function () {
|
|
|
449
457
|
*/
|
|
450
458
|
UpgradeAdapter.prototype.upgradeNg1Provider = function (name, options) {
|
|
451
459
|
var token = options && options.asToken || name;
|
|
452
|
-
this.providers.push(
|
|
460
|
+
this.providers.push({
|
|
461
|
+
provide: token,
|
|
453
462
|
useFactory: function (ng1Injector) { return ng1Injector.get(name); },
|
|
454
463
|
deps: [constants_1.NG1_INJECTOR]
|
|
455
|
-
})
|
|
464
|
+
});
|
|
456
465
|
};
|
|
457
466
|
/**
|
|
458
467
|
* Allows Angular v2 service to be accessible from AngularJS v1.
|
|
@@ -501,18 +510,21 @@ var UpgradeAdapter = (function () {
|
|
|
501
510
|
}());
|
|
502
511
|
exports.UpgradeAdapter = UpgradeAdapter;
|
|
503
512
|
function ng1ComponentDirective(info, idPrefix) {
|
|
504
|
-
directiveFactory.$inject = [constants_1.NG2_COMPONENT_FACTORY_REF_MAP, constants_1.NG1_PARSE];
|
|
505
|
-
function directiveFactory(componentFactoryRefMap, parse) {
|
|
506
|
-
var componentFactory = componentFactoryRefMap[info.selector];
|
|
507
|
-
if (!componentFactory)
|
|
508
|
-
throw new Error('Expecting ComponentFactory for: ' + info.selector);
|
|
513
|
+
directiveFactory.$inject = [constants_1.NG1_INJECTOR, constants_1.NG2_COMPONENT_FACTORY_REF_MAP, constants_1.NG1_PARSE];
|
|
514
|
+
function directiveFactory(ng1Injector, componentFactoryRefMap, parse) {
|
|
509
515
|
var idCount = 0;
|
|
510
516
|
return {
|
|
511
517
|
restrict: 'E',
|
|
512
518
|
require: constants_1.REQUIRE_INJECTOR,
|
|
513
519
|
link: {
|
|
514
520
|
post: function (scope, element, attrs, parentInjector, transclude) {
|
|
521
|
+
var componentFactory = componentFactoryRefMap[info.selector];
|
|
522
|
+
if (!componentFactory)
|
|
523
|
+
throw new Error('Expecting ComponentFactory for: ' + info.selector);
|
|
515
524
|
var domElement = element[0];
|
|
525
|
+
if (parentInjector === null) {
|
|
526
|
+
parentInjector = ng1Injector.get(constants_1.NG2_INJECTOR);
|
|
527
|
+
}
|
|
516
528
|
var facade = new downgrade_ng2_adapter_1.DowngradeNg2ComponentAdapter(idPrefix + (idCount++), info, element, attrs, scope, parentInjector, parse, componentFactory);
|
|
517
529
|
facade.setupInputs();
|
|
518
530
|
facade.bootstrapNg2();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upgrade_adapter.js","sourceRoot":"","sources":["../../../../modules/@angular/upgrade/src/upgrade_adapter.ts"],"names":[],"mappings":";AAIE,qBAYK,eAAe,CAAC,CAAA;AACvB,yCAA4C,mCAAmC,CAAC,CAAA;AAChF,iCAA8B,2BAA2B,CAAC,CAAA;AAC1D,yBAA8C,YAAY,CAAC,CAAA;AAC3D,qBAAqC,QAAQ,CAAC,CAAA;AAC9C,0BAWO,aAAa,CAAC,CAAA;AACrB,sCAA2C,yBAAyB,CAAC,CAAA;AACrE,oCAAgD,uBAAuB,CAAC,CAAA;AACxE,IAAY,OAAO,WAAM,cAAc,CAAC,CAAA;AAExC,IAAI,YAAY,GAAW,CAAC,CAAC;AAE7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH;IAAA;QACE,eAAe;QACP,aAAQ,GAAW,iBAAe,YAAY,EAAE,MAAG,CAAC;QAC5D,eAAe;QACP,uBAAkB,GAAW,EAAE,CAAC;QACxC,eAAe;QACP,yBAAoB,GAAwD,EAAE,CAAC;QACvF,eAAe;QACP,cAAS,GAAmC,EAAE,CAAC;IAuazD,CAAC;IAraC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgDG;IACH,8CAAqB,GAArB,UAAsB,IAAU;QAC9B,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,IAAI,GAAkB,2BAAgB,CAAC,IAAI,CAAC,CAAC;QACjD,MA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AC;QAC3C,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC,GAAG,CAAC,0BAAc,CAAC,CAAC;QACpD,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;IAED;;;;;;OAMG;IACI,iCAAK,GAAZ,UAAa,EAAmD,IAAI,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC,CAAC,CAAC;IAEzF;;OAEG;IACI,mCAAO,GAAd;QACE,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,0BAAc,CAAC,CAAC,QAAQ,EAAE,CAAC;QAChD,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,CAAC;IACnC,CAAC;IACH,wBAAC;AAAD,CAAC,AAlCD,IAkCC;AAlCY,yBAAiB,oBAkC7B,CAAA","sourcesContent":["interface DecoratorInvocation {\n type: Function;\n args?: any[];\n }\n import {\n provide,\n ApplicationRef,\n ComponentResolver,\n Injector,\n NgZone,\n PlatformRef,\n ReflectiveInjector,\n ComponentFactory,\n Provider,\n Type,\n Testability\n} from '@angular/core';\nimport {BROWSER_APP_DYNAMIC_PROVIDERS} from '@angular/platform-browser-dynamic';\nimport {browserPlatform} from '@angular/platform-browser';\nimport {getComponentInfo, ComponentInfo} from './metadata';\nimport {onError, controllerKey} from './util';\nimport {\n NG1_COMPILE,\n NG1_INJECTOR,\n NG1_PARSE,\n NG1_ROOT_SCOPE,\n NG1_TESTABILITY,\n NG2_COMPILER,\n NG2_INJECTOR,\n NG2_COMPONENT_FACTORY_REF_MAP,\n NG2_ZONE,\n REQUIRE_INJECTOR\n} from './constants';\nimport {DowngradeNg2ComponentAdapter} from './downgrade_ng2_adapter';\nimport {UpgradeNg1ComponentAdapterBuilder} from './upgrade_ng1_adapter';\nimport * as angular from './angular_js';\n\nvar upgradeCount: number = 0;\n\n/**\n * Use `UpgradeAdapter` to allow AngularJS v1 and Angular v2 to coexist in a single application.\n *\n * The `UpgradeAdapter` allows:\n * 1. creation of Angular v2 component from AngularJS v1 component directive\n * (See [UpgradeAdapter#upgradeNg1Component()])\n * 2. creation of AngularJS v1 directive from Angular v2 component.\n * (See [UpgradeAdapter#downgradeNg2Component()])\n * 3. Bootstrapping of a hybrid Angular application which contains both of the frameworks\n * coexisting in a single application.\n *\n * ## Mental Model\n *\n * When reasoning about how a hybrid application works it is useful to have a mental model which\n * describes what is happening and explains what is happening at the lowest level.\n *\n * 1. There are two independent frameworks running in a single application, each framework treats\n * the other as a black box.\n * 2. Each DOM element on the page is owned exactly by one framework. Whichever framework\n * instantiated the element is the owner. Each framework only updates/interacts with its own\n * DOM elements and ignores others.\n * 3. AngularJS v1 directives always execute inside AngularJS v1 framework codebase regardless of\n * where they are instantiated.\n * 4. Angular v2 components always execute inside Angular v2 framework codebase regardless of\n * where they are instantiated.\n * 5. An AngularJS v1 component can be upgraded to an Angular v2 component. This creates an\n * Angular v2 directive, which bootstraps the AngularJS v1 component directive in that location.\n * 6. An Angular v2 component can be downgraded to an AngularJS v1 component directive. This creates\n * an AngularJS v1 directive, which bootstraps the Angular v2 component in that location.\n * 7. Whenever an adapter component is instantiated the host element is owned by the framework\n * doing the instantiation. The other framework then instantiates and owns the view for that\n * component. This implies that component bindings will always follow the semantics of the\n * instantiation framework. The syntax is always that of Angular v2 syntax.\n * 8. AngularJS v1 is always bootstrapped first and owns the bottom most view.\n * 9. The new application is running in Angular v2 zone, and therefore it no longer needs calls to\n * `$apply()`.\n *\n * ### Example\n *\n * ```\n * var adapter = new UpgradeAdapter();\n * var module = angular.module('myExample', []);\n * module.directive('ng2', adapter.downgradeNg2Component(Ng2));\n *\n * module.directive('ng1', function() {\n * return {\n * scope: { title: '=' },\n * template: 'ng1[Hello {{title}}!](<span ng-transclude></span>)'\n * };\n * });\n *\n *\n * @Component({\n * selector: 'ng2',\n * inputs: ['name'],\n * template: 'ng2[<ng1 [title]=\"name\">transclude</ng1>](<ng-content></ng-content>)',\n * directives: [adapter.upgradeNg1Component('ng1')]\n * })\n * class Ng2 {\n * }\n *\n * document.body.innerHTML = '<ng2 name=\"World\">project</ng2>';\n *\n * adapter.bootstrap(document.body, ['myExample']).ready(function() {\n * expect(document.body.textContent).toEqual(\n * \"ng2[ng1[Hello World!](transclude)](project)\");\n * });\n * ```\n */\nexport class UpgradeAdapter {\n /* @internal */\n private idPrefix: string = `NG2_UPGRADE_${upgradeCount++}_`;\n /* @internal */\n private upgradedComponents: Type[] = [];\n /* @internal */\n private downgradedComponents: {[name: string]: UpgradeNg1ComponentAdapterBuilder} = {};\n /* @internal */\n private providers: Array<Type | Provider | any[]> = [];\n\n /**\n * Allows Angular v2 Component to be used from AngularJS v1.\n *\n * Use `downgradeNg2Component` to create an AngularJS v1 Directive Definition Factory from\n * Angular v2 Component. The adapter will bootstrap Angular v2 component from within the\n * AngularJS v1 template.\n *\n * ## Mental Model\n *\n * 1. The component is instantiated by being listed in AngularJS v1 template. This means that the\n * host element is controlled by AngularJS v1, but the component's view will be controlled by\n * Angular v2.\n * 2. Even thought the component is instantiated in AngularJS v1, it will be using Angular v2\n * syntax. This has to be done, this way because we must follow Angular v2 components do not\n * declare how the attributes should be interpreted.\n *\n * ## Supported Features\n *\n * - Bindings:\n * - Attribute: `<comp name=\"World\">`\n * - Interpolation: `<comp greeting=\"Hello {{name}}!\">`\n * - Expression: `<comp [name]=\"username\">`\n * - Event: `<comp (close)=\"doSomething()\">`\n * - Content projection: yes\n *\n * ### Example\n *\n * ```\n * var adapter = new UpgradeAdapter();\n * var module = angular.module('myExample', []);\n * module.directive('greet', adapter.downgradeNg2Component(Greeter));\n *\n * @Component({\n * selector: 'greet',\n * template: '{{salutation}} {{name}}! - <ng-content></ng-content>'\n * })\n * class Greeter {\n * @Input() salutation: string;\n * @Input() name: string;\n * }\n *\n * document.body.innerHTML =\n * 'ng1 template: <greet salutation=\"Hello\" [name]=\"world\">text</greet>';\n *\n * adapter.bootstrap(document.body, ['myExample']).ready(function() {\n * expect(document.body.textContent).toEqual(\"ng1 template: Hello world! - text\");\n * });\n * ```\n */\n downgradeNg2Component(type: Type): Function {\n this.upgradedComponents.push(type);\n var info: ComponentInfo = getComponentInfo(type);\n return ng1ComponentDirective(info, `${this.idPrefix}${info.selector}_c`);\n }\n\n /**\n * Allows AngularJS v1 Component to be used from Angular v2.\n *\n * Use `upgradeNg1Component` to create an Angular v2 component from AngularJS v1 Component\n * directive. The adapter will bootstrap AngularJS v1 component from within the Angular v2\n * template.\n *\n * ## Mental Model\n *\n * 1. The component is instantiated by being listed in Angular v2 template. This means that the\n * host element is controlled by Angular v2, but the component's view will be controlled by\n * AngularJS v1.\n *\n * ## Supported Features\n *\n * - Bindings:\n * - Attribute: `<comp name=\"World\">`\n * - Interpolation: `<comp greeting=\"Hello {{name}}!\">`\n * - Expression: `<comp [name]=\"username\">`\n * - Event: `<comp (close)=\"doSomething()\">`\n * - Transclusion: yes\n * - Only some of the features of\n * [Directive Definition Object](https://docs.angularjs.org/api/ng/service/$compile) are\n * supported:\n * - `compile`: not supported because the host element is owned by Angular v2, which does\n * not allow modifying DOM structure during compilation.\n * - `controller`: supported. (NOTE: injection of `$attrs` and `$transclude` is not supported.)\n * - `controllerAs': supported.\n * - `bindToController': supported.\n * - `link': supported. (NOTE: only pre-link function is supported.)\n * - `name': supported.\n * - `priority': ignored.\n * - `replace': not supported.\n * - `require`: supported.\n * - `restrict`: must be set to 'E'.\n * - `scope`: supported.\n * - `template`: supported.\n * - `templateUrl`: supported.\n * - `terminal`: ignored.\n * - `transclude`: supported.\n *\n *\n * ### Example\n *\n * ```\n * var adapter = new UpgradeAdapter();\n * var module = angular.module('myExample', []);\n *\n * module.directive('greet', function() {\n * return {\n * scope: {salutation: '=', name: '=' },\n * template: '{{salutation}} {{name}}! - <span ng-transclude></span>'\n * };\n * });\n *\n * module.directive('ng2', adapter.downgradeNg2Component(Ng2));\n *\n * @Component({\n * selector: 'ng2',\n * template: 'ng2 template: <greet salutation=\"Hello\" [name]=\"world\">text</greet>'\n * directives: [adapter.upgradeNg1Component('greet')]\n * })\n * class Ng2 {\n * }\n *\n * document.body.innerHTML = '<ng2></ng2>';\n *\n * adapter.bootstrap(document.body, ['myExample']).ready(function() {\n * expect(document.body.textContent).toEqual(\"ng2 template: Hello world! - text\");\n * });\n * ```\n */\n upgradeNg1Component(name: string): Type {\n if ((<any>this.downgradedComponents).hasOwnProperty(name)) {\n return this.downgradedComponents[name].type;\n } else {\n return (this.downgradedComponents[name] = new UpgradeNg1ComponentAdapterBuilder(name)).type;\n }\n }\n\n /**\n * Bootstrap a hybrid AngularJS v1 / Angular v2 application.\n *\n * This `bootstrap` method is a direct replacement (takes same arguments) for AngularJS v1\n * [`bootstrap`](https://docs.angularjs.org/api/ng/function/angular.bootstrap) method. Unlike\n * AngularJS v1, this bootstrap is asynchronous.\n *\n * ### Example\n *\n * ```\n * var adapter = new UpgradeAdapter();\n * var module = angular.module('myExample', []);\n * module.directive('ng2', adapter.downgradeNg2Component(Ng2));\n *\n * module.directive('ng1', function() {\n * return {\n * scope: { title: '=' },\n * template: 'ng1[Hello {{title}}!](<span ng-transclude></span>)'\n * };\n * });\n *\n *\n * @Component({\n * selector: 'ng2',\n * inputs: ['name'],\n * template: 'ng2[<ng1 [title]=\"name\">transclude</ng1>](<ng-content></ng-content>)',\n * directives: [adapter.upgradeNg1Component('ng1')]\n * })\n * class Ng2 {\n * }\n *\n * document.body.innerHTML = '<ng2 name=\"World\">project</ng2>';\n *\n * adapter.bootstrap(document.body, ['myExample']).ready(function() {\n * expect(document.body.textContent).toEqual(\n * \"ng2[ng1[Hello World!](transclude)](project)\");\n * });\n * ```\n */\n bootstrap(element: Element, modules?: any[],\n config?: angular.IAngularBootstrapConfig): UpgradeAdapterRef {\n var upgrade = new UpgradeAdapterRef();\n var ng1Injector: angular.IInjectorService = null;\n var platformRef: PlatformRef = browserPlatform();\n var applicationRef: ApplicationRef =\n ReflectiveInjector.resolveAndCreate(\n [\n BROWSER_APP_DYNAMIC_PROVIDERS,\n provide(NG1_INJECTOR, {useFactory: () => ng1Injector}),\n provide(NG1_COMPILE,\n {useFactory: () => ng1Injector.get(NG1_COMPILE)}),\n this.providers\n ],\n platformRef.injector)\n .get(ApplicationRef);\n var injector: Injector = applicationRef.injector;\n var ngZone: NgZone = injector.get(NgZone);\n var compiler: ComponentResolver = injector.get(ComponentResolver);\n var delayApplyExps: Function[] = [];\n var original$applyFn: Function;\n var rootScopePrototype: any;\n var rootScope: angular.IRootScopeService;\n var componentFactoryRefMap: ComponentFactoryRefMap = {};\n var ng1Module = angular.module(this.idPrefix, modules);\n var ng1BootstrapPromise: Promise<any> = null;\n var ng1compilePromise: Promise<any> = null;\n ng1Module.value(NG2_INJECTOR, injector)\n .value(NG2_ZONE, ngZone)\n .value(NG2_COMPILER, compiler)\n .value(NG2_COMPONENT_FACTORY_REF_MAP, componentFactoryRefMap)\n .config([\n '$provide',\n (provide) => {\n provide.decorator(NG1_ROOT_SCOPE, [\n '$delegate',\n function(rootScopeDelegate: angular.IRootScopeService) {\n rootScopePrototype = rootScopeDelegate.constructor.prototype;\n if (rootScopePrototype.hasOwnProperty('$apply')) {\n original$applyFn = rootScopePrototype.$apply;\n rootScopePrototype.$apply = (exp) => delayApplyExps.push(exp);\n } else {\n throw new Error(\"Failed to find '$apply' on '$rootScope'!\");\n }\n return rootScope = rootScopeDelegate;\n }\n ]);\n provide.decorator(NG1_TESTABILITY, [\n '$delegate',\n function(testabilityDelegate: angular.ITestabilityService) {\n var ng2Testability: Testability = injector.get(Testability);\n\n var origonalWhenStable: Function = testabilityDelegate.whenStable;\n var newWhenStable = (callback: Function): void => {\n var whenStableContext: any = this;\n origonalWhenStable.call(this, function() {\n if (ng2Testability.isStable()) {\n callback.apply(this, arguments);\n } else {\n ng2Testability.whenStable(newWhenStable.bind(whenStableContext, callback));\n }\n });\n };\n\n testabilityDelegate.whenStable = newWhenStable;\n return testabilityDelegate;\n }\n ]);\n }\n ]);\n\n ng1compilePromise = new Promise((resolve, reject) => {\n ng1Module.run([\n '$injector',\n '$rootScope',\n (injector: angular.IInjectorService, rootScope: angular.IRootScopeService) => {\n ng1Injector = injector;\n ngZone.onMicrotaskEmpty.subscribe(\n {next: (_) => ngZone.runOutsideAngular(() => rootScope.$apply())});\n UpgradeNg1ComponentAdapterBuilder.resolve(this.downgradedComponents, injector)\n .then(resolve, reject);\n }\n ]);\n });\n\n // Make sure resumeBootstrap() only exists if the current bootstrap is deferred\n var windowAngular = window['angular'];\n windowAngular.resumeBootstrap = undefined;\n\n angular.element(element).data(controllerKey(NG2_INJECTOR), injector);\n ngZone.run(() => { angular.bootstrap(element, [this.idPrefix], config); });\n ng1BootstrapPromise = new Promise((resolve, reject) => {\n if (windowAngular.resumeBootstrap) {\n var originalResumeBootstrap: () => void = windowAngular.resumeBootstrap;\n windowAngular.resumeBootstrap = function() {\n windowAngular.resumeBootstrap = originalResumeBootstrap;\n windowAngular.resumeBootstrap.apply(this, arguments);\n resolve();\n };\n } else {\n resolve();\n }\n });\n\n Promise.all([\n this.compileNg2Components(compiler, componentFactoryRefMap),\n ng1BootstrapPromise,\n ng1compilePromise\n ])\n .then(() => {\n ngZone.run(() => {\n if (rootScopePrototype) {\n rootScopePrototype.$apply = original$applyFn; // restore original $apply\n while (delayApplyExps.length) {\n rootScope.$apply(delayApplyExps.shift());\n }\n (<any>upgrade)._bootstrapDone(applicationRef, ng1Injector);\n rootScopePrototype = null;\n }\n });\n }, onError);\n return upgrade;\n }\n\n /**\n * Adds a provider to the top level environment of a hybrid AngularJS v1 / Angular v2 application.\n *\n * In hybrid AngularJS v1 / Angular v2 application, there is no one root Angular v2 component,\n * for this reason we provide an application global way of registering providers which is\n * consistent with single global injection in AngularJS v1.\n *\n * ### Example\n *\n * ```\n * class Greeter {\n * greet(name) {\n * alert('Hello ' + name + '!');\n * }\n * }\n *\n * @Component({\n * selector: 'app',\n * template: ''\n * })\n * class App {\n * constructor(greeter: Greeter) {\n * this.greeter('World');\n * }\n * }\n *\n * var adapter = new UpgradeAdapter();\n * adapter.addProvider(Greeter);\n *\n * var module = angular.module('myExample', []);\n * module.directive('app', adapter.downgradeNg2Component(App));\n *\n * document.body.innerHTML = '<app></app>'\n * adapter.bootstrap(document.body, ['myExample']);\n *```\n */\n public addProvider(provider: Type | Provider | any[]): void { this.providers.push(provider); }\n\n /**\n * Allows AngularJS v1 service to be accessible from Angular v2.\n *\n *\n * ### Example\n *\n * ```\n * class Login { ... }\n * class Server { ... }\n *\n * @Injectable()\n * class Example {\n * constructor(@Inject('server') server, login: Login) {\n * ...\n * }\n * }\n *\n * var module = angular.module('myExample', []);\n * module.service('server', Server);\n * module.service('login', Login);\n *\n * var adapter = new UpgradeAdapter();\n * adapter.upgradeNg1Provider('server');\n * adapter.upgradeNg1Provider('login', {asToken: Login});\n * adapter.addProvider(Example);\n *\n * adapter.bootstrap(document.body, ['myExample']).ready((ref) => {\n * var example: Example = ref.ng2Injector.get(Example);\n * });\n *\n * ```\n */\n public upgradeNg1Provider(name: string, options?: {asToken: any}) {\n var token = options && options.asToken || name;\n this.providers.push(provide(token, {\n useFactory: (ng1Injector: angular.IInjectorService) => ng1Injector.get(name),\n deps: [NG1_INJECTOR]\n }));\n }\n\n /**\n * Allows Angular v2 service to be accessible from AngularJS v1.\n *\n *\n * ### Example\n *\n * ```\n * class Example {\n * }\n *\n * var adapter = new UpgradeAdapter();\n * adapter.addProvider(Example);\n *\n * var module = angular.module('myExample', []);\n * module.factory('example', adapter.downgradeNg2Provider(Example));\n *\n * adapter.bootstrap(document.body, ['myExample']).ready((ref) => {\n * var example: Example = ref.ng1Injector.get('example');\n * });\n *\n * ```\n */\n public downgradeNg2Provider(token: any): Function {\n var factory = function(injector: Injector) { return injector.get(token); };\n (<any>factory).$inject = [NG2_INJECTOR];\n return factory;\n }\n\n /* @internal */\n private compileNg2Components(compiler: ComponentResolver,\n componentFactoryRefMap: ComponentFactoryRefMap):\n Promise<ComponentFactoryRefMap> {\n var promises: Array<Promise<ComponentFactory<any>>> = [];\n var types = this.upgradedComponents;\n for (var i = 0; i < types.length; i++) {\n promises.push(compiler.resolveComponent(types[i]));\n }\n return Promise.all(promises).then((componentFactories: Array<ComponentFactory<any>>) => {\n var types = this.upgradedComponents;\n for (var i = 0; i < componentFactories.length; i++) {\n componentFactoryRefMap[getComponentInfo(types[i]).selector] = componentFactories[i];\n }\n return componentFactoryRefMap;\n }, onError);\n }\n}\n\ninterface ComponentFactoryRefMap {\n [selector: string]: ComponentFactory<any>;\n}\n\nfunction ng1ComponentDirective(info: ComponentInfo, idPrefix: string): Function {\n (<any>directiveFactory).$inject = [NG2_COMPONENT_FACTORY_REF_MAP, NG1_PARSE];\n function directiveFactory(componentFactoryRefMap: ComponentFactoryRefMap,\n parse: angular.IParseService): angular.IDirective {\n var componentFactory: ComponentFactory<any> = componentFactoryRefMap[info.selector];\n if (!componentFactory) throw new Error('Expecting ComponentFactory for: ' + info.selector);\n var idCount = 0;\n return {\n restrict: 'E',\n require: REQUIRE_INJECTOR,\n link: {\n post: (scope: angular.IScope, element: angular.IAugmentedJQuery, attrs: angular.IAttributes,\n parentInjector: any, transclude: angular.ITranscludeFunction): void => {\n var domElement = <any>element[0];\n var facade =\n new DowngradeNg2ComponentAdapter(idPrefix + (idCount++), info, element, attrs, scope,\n <Injector>parentInjector, parse, componentFactory);\n facade.setupInputs();\n facade.bootstrapNg2();\n facade.projectContent();\n facade.setupOutputs();\n facade.registerCleanup();\n }\n }\n };\n }\n return directiveFactory;\n}\n\n/**\n * Use `UgradeAdapterRef` to control a hybrid AngularJS v1 / Angular v2 application.\n */\nexport class UpgradeAdapterRef {\n /* @internal */\n private _readyFn: (upgradeAdapterRef?: UpgradeAdapterRef) => void = null;\n\n public ng1RootScope: angular.IRootScopeService = null;\n public ng1Injector: angular.IInjectorService = null;\n public ng2ApplicationRef: ApplicationRef = null;\n public ng2Injector: Injector = null;\n\n /* @internal */\n private _bootstrapDone(applicationRef: ApplicationRef, ng1Injector: angular.IInjectorService) {\n this.ng2ApplicationRef = applicationRef;\n this.ng2Injector = applicationRef.injector;\n this.ng1Injector = ng1Injector;\n this.ng1RootScope = ng1Injector.get(NG1_ROOT_SCOPE);\n this._readyFn && this._readyFn(this);\n }\n\n /**\n * Register a callback function which is notified upon successful hybrid AngularJS v1 / Angular v2\n * application has been bootstrapped.\n *\n * The `ready` callback function is invoked inside the Angular v2 zone, therefore it does not\n * require a call to `$apply()`.\n */\n public ready(fn: (upgradeAdapterRef?: UpgradeAdapterRef) => void) { this._readyFn = fn; }\n\n /**\n * Dispose of running hybrid AngularJS v1 / Angular v2 application.\n */\n public dispose() {\n this.ng1Injector.get(NG1_ROOT_SCOPE).$destroy();\n this.ng2ApplicationRef.dispose();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"upgrade_adapter.js","sourceRoot":"","sources":["../../../../modules/@angular/upgrade/src/upgrade_adapter.ts"],"names":[],"mappings":";AAAA,qBAA2J,eAAe,CAAC,CAAA;AAC3K,iCAAqD,2BAA2B,CAAC,CAAA;AACjF,yCAA6C,mCAAmC,CAAC,CAAA;AAEjF,IAAY,OAAO,WAAM,cAAc,CAAC,CAAA;AACxC,0BAA2K,aAAa,CAAC,CAAA;AACzL,sCAA2C,yBAAyB,CAAC,CAAA;AACrE,yBAA8C,YAAY,CAAC,CAAA;AAC3D,oCAAgD,uBAAuB,CAAC,CAAA;AACxE,qBAAqC,QAAQ,CAAC,CAAA;AAE9C,IAAI,YAAY,GAAW,CAAC,CAAC;AAE7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH;IAAA;QACE,eAAe;QACP,aAAQ,GAAW,iBAAe,YAAY,EAAE,MAAG,CAAC;QAC5D,eAAe;QACP,uBAAkB,GAAW,EAAE,CAAC;QACxC,eAAe;QACP,yBAAoB,GAAwD,EAAE,CAAC;QACvF,eAAe;QACP,cAAS,GAAmC,EAAE,CAAC;IA4azD,CAA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C;oBACtB,MAAM,CAAC,cAAc,EAAE,CAAC;oBACxB,MAAM,CAAC,YAAY,EAAE,CAAC;oBACtB,MAAM,CAAC,eAAe,EAAE,CAAC;gBAC3B,CAAC;aACF;SACF,CAAC;IACJ,CAAC;IACD,MAAM,CAAC,gBAAgB,CAAC;AAC1B,CAAC;AAED;;GAEG;AACH;IAAA;QACE,eAAe;QACP,aAAQ,GAAoD,IAAI,CAAC;QAElE,iBAAY,GAA8B,IAAI,CAAC;QAC/C,gBAAW,GAA6B,IAAI,CAAC;QAC7C,sBAAiB,GAAmB,IAAI,CAAC;QACzC,gBAAW,GAAa,IAAI,CAAC;IA2BtC,CAAC;IAzBC,eAAe;IACP,0CAAc,GAAtB,UAAuB,cAA8B,EAAE,WAAqC;QAC1F,IAAI,CAAC,iBAAiB,GAAG,cAAc,CAAC;QACxC,IAAI,CAAC,WAAW,GAAG,cAAc,CAAC,QAAQ,CAAC;QAC3C,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC,GAAG,CAAC,0BAAc,CAAC,CAAC;QACpD,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;IAED;;;;;;OAMG;IACI,iCAAK,GAAZ,UAAa,EAAmD,IAAI,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC,CAAC,CAAC;IAEzF;;OAEG;IACI,mCAAO,GAAd;QACE,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,0BAAc,CAAC,CAAC,QAAQ,EAAE,CAAC;QAChD,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,CAAC;IACnC,CAAC;IACH,wBAAC;AAAD,CAAC,AAlCD,IAkCC;AAlCY,yBAAiB,oBAkC7B,CAAA","sourcesContent":["import {ApplicationRef, ComponentFactory, ComponentResolver, Injector, NgZone, PlatformRef, Provider, ReflectiveInjector, Testability, Type, provide} from '@angular/core';\nimport {BROWSER_APP_PROVIDERS, browserPlatform} from '@angular/platform-browser';\nimport {BROWSER_APP_COMPILER_PROVIDERS} from '@angular/platform-browser-dynamic';\n\nimport * as angular from './angular_js';\nimport {NG1_COMPILE, NG1_INJECTOR, NG1_PARSE, NG1_ROOT_SCOPE, NG1_TESTABILITY, NG2_COMPILER, NG2_COMPONENT_FACTORY_REF_MAP, NG2_INJECTOR, NG2_ZONE, REQUIRE_INJECTOR} from './constants';\nimport {DowngradeNg2ComponentAdapter} from './downgrade_ng2_adapter';\nimport {ComponentInfo, getComponentInfo} from './metadata';\nimport {UpgradeNg1ComponentAdapterBuilder} from './upgrade_ng1_adapter';\nimport {controllerKey, onError} from './util';\n\nvar upgradeCount: number = 0;\n\n/**\n * Use `UpgradeAdapter` to allow AngularJS v1 and Angular v2 to coexist in a single application.\n *\n * The `UpgradeAdapter` allows:\n * 1. creation of Angular v2 component from AngularJS v1 component directive\n * (See [UpgradeAdapter#upgradeNg1Component()])\n * 2. creation of AngularJS v1 directive from Angular v2 component.\n * (See [UpgradeAdapter#downgradeNg2Component()])\n * 3. Bootstrapping of a hybrid Angular application which contains both of the frameworks\n * coexisting in a single application.\n *\n * ## Mental Model\n *\n * When reasoning about how a hybrid application works it is useful to have a mental model which\n * describes what is happening and explains what is happening at the lowest level.\n *\n * 1. There are two independent frameworks running in a single application, each framework treats\n * the other as a black box.\n * 2. Each DOM element on the page is owned exactly by one framework. Whichever framework\n * instantiated the element is the owner. Each framework only updates/interacts with its own\n * DOM elements and ignores others.\n * 3. AngularJS v1 directives always execute inside AngularJS v1 framework codebase regardless of\n * where they are instantiated.\n * 4. Angular v2 components always execute inside Angular v2 framework codebase regardless of\n * where they are instantiated.\n * 5. An AngularJS v1 component can be upgraded to an Angular v2 component. This creates an\n * Angular v2 directive, which bootstraps the AngularJS v1 component directive in that location.\n * 6. An Angular v2 component can be downgraded to an AngularJS v1 component directive. This creates\n * an AngularJS v1 directive, which bootstraps the Angular v2 component in that location.\n * 7. Whenever an adapter component is instantiated the host element is owned by the framework\n * doing the instantiation. The other framework then instantiates and owns the view for that\n * component. This implies that component bindings will always follow the semantics of the\n * instantiation framework. The syntax is always that of Angular v2 syntax.\n * 8. AngularJS v1 is always bootstrapped first and owns the bottom most view.\n * 9. The new application is running in Angular v2 zone, and therefore it no longer needs calls to\n * `$apply()`.\n *\n * ### Example\n *\n * ```\n * var adapter = new UpgradeAdapter();\n * var module = angular.module('myExample', []);\n * module.directive('ng2', adapter.downgradeNg2Component(Ng2));\n *\n * module.directive('ng1', function() {\n * return {\n * scope: { title: '=' },\n * template: 'ng1[Hello {{title}}!](<span ng-transclude></span>)'\n * };\n * });\n *\n *\n * @Component({\n * selector: 'ng2',\n * inputs: ['name'],\n * template: 'ng2[<ng1 [title]=\"name\">transclude</ng1>](<ng-content></ng-content>)',\n * directives: [adapter.upgradeNg1Component('ng1')]\n * })\n * class Ng2 {\n * }\n *\n * document.body.innerHTML = '<ng2 name=\"World\">project</ng2>';\n *\n * adapter.bootstrap(document.body, ['myExample']).ready(function() {\n * expect(document.body.textContent).toEqual(\n * \"ng2[ng1[Hello World!](transclude)](project)\");\n * });\n * ```\n */\nexport class UpgradeAdapter {\n /* @internal */\n private idPrefix: string = `NG2_UPGRADE_${upgradeCount++}_`;\n /* @internal */\n private upgradedComponents: Type[] = [];\n /* @internal */\n private downgradedComponents: {[name: string]: UpgradeNg1ComponentAdapterBuilder} = {};\n /* @internal */\n private providers: Array<Type|Provider|any[]|any> = [];\n\n /**\n * Allows Angular v2 Component to be used from AngularJS v1.\n *\n * Use `downgradeNg2Component` to create an AngularJS v1 Directive Definition Factory from\n * Angular v2 Component. The adapter will bootstrap Angular v2 component from within the\n * AngularJS v1 template.\n *\n * ## Mental Model\n *\n * 1. The component is instantiated by being listed in AngularJS v1 template. This means that the\n * host element is controlled by AngularJS v1, but the component's view will be controlled by\n * Angular v2.\n * 2. Even thought the component is instantiated in AngularJS v1, it will be using Angular v2\n * syntax. This has to be done, this way because we must follow Angular v2 components do not\n * declare how the attributes should be interpreted.\n *\n * ## Supported Features\n *\n * - Bindings:\n * - Attribute: `<comp name=\"World\">`\n * - Interpolation: `<comp greeting=\"Hello {{name}}!\">`\n * - Expression: `<comp [name]=\"username\">`\n * - Event: `<comp (close)=\"doSomething()\">`\n * - Content projection: yes\n *\n * ### Example\n *\n * ```\n * var adapter = new UpgradeAdapter();\n * var module = angular.module('myExample', []);\n * module.directive('greet', adapter.downgradeNg2Component(Greeter));\n *\n * @Component({\n * selector: 'greet',\n * template: '{{salutation}} {{name}}! - <ng-content></ng-content>'\n * })\n * class Greeter {\n * @Input() salutation: string;\n * @Input() name: string;\n * }\n *\n * document.body.innerHTML =\n * 'ng1 template: <greet salutation=\"Hello\" [name]=\"world\">text</greet>';\n *\n * adapter.bootstrap(document.body, ['myExample']).ready(function() {\n * expect(document.body.textContent).toEqual(\"ng1 template: Hello world! - text\");\n * });\n * ```\n */\n downgradeNg2Component(type: Type): Function {\n this.upgradedComponents.push(type);\n var info: ComponentInfo = getComponentInfo(type);\n return ng1ComponentDirective(info, `${this.idPrefix}${info.selector}_c`);\n }\n\n /**\n * Allows AngularJS v1 Component to be used from Angular v2.\n *\n * Use `upgradeNg1Component` to create an Angular v2 component from AngularJS v1 Component\n * directive. The adapter will bootstrap AngularJS v1 component from within the Angular v2\n * template.\n *\n * ## Mental Model\n *\n * 1. The component is instantiated by being listed in Angular v2 template. This means that the\n * host element is controlled by Angular v2, but the component's view will be controlled by\n * AngularJS v1.\n *\n * ## Supported Features\n *\n * - Bindings:\n * - Attribute: `<comp name=\"World\">`\n * - Interpolation: `<comp greeting=\"Hello {{name}}!\">`\n * - Expression: `<comp [name]=\"username\">`\n * - Event: `<comp (close)=\"doSomething()\">`\n * - Transclusion: yes\n * - Only some of the features of\n * [Directive Definition Object](https://docs.angularjs.org/api/ng/service/$compile) are\n * supported:\n * - `compile`: not supported because the host element is owned by Angular v2, which does\n * not allow modifying DOM structure during compilation.\n * - `controller`: supported. (NOTE: injection of `$attrs` and `$transclude` is not supported.)\n * - `controllerAs': supported.\n * - `bindToController': supported.\n * - `link': supported. (NOTE: only pre-link function is supported.)\n * - `name': supported.\n * - `priority': ignored.\n * - `replace': not supported.\n * - `require`: supported.\n * - `restrict`: must be set to 'E'.\n * - `scope`: supported.\n * - `template`: supported.\n * - `templateUrl`: supported.\n * - `terminal`: ignored.\n * - `transclude`: supported.\n *\n *\n * ### Example\n *\n * ```\n * var adapter = new UpgradeAdapter();\n * var module = angular.module('myExample', []);\n *\n * module.directive('greet', function() {\n * return {\n * scope: {salutation: '=', name: '=' },\n * template: '{{salutation}} {{name}}! - <span ng-transclude></span>'\n * };\n * });\n *\n * module.directive('ng2', adapter.downgradeNg2Component(Ng2));\n *\n * @Component({\n * selector: 'ng2',\n * template: 'ng2 template: <greet salutation=\"Hello\" [name]=\"world\">text</greet>'\n * directives: [adapter.upgradeNg1Component('greet')]\n * })\n * class Ng2 {\n * }\n *\n * document.body.innerHTML = '<ng2></ng2>';\n *\n * adapter.bootstrap(document.body, ['myExample']).ready(function() {\n * expect(document.body.textContent).toEqual(\"ng2 template: Hello world! - text\");\n * });\n * ```\n */\n upgradeNg1Component(name: string): Type {\n if ((<any>this.downgradedComponents).hasOwnProperty(name)) {\n return this.downgradedComponents[name].type;\n } else {\n return (this.downgradedComponents[name] = new UpgradeNg1ComponentAdapterBuilder(name)).type;\n }\n }\n\n /**\n * Bootstrap a hybrid AngularJS v1 / Angular v2 application.\n *\n * This `bootstrap` method is a direct replacement (takes same arguments) for AngularJS v1\n * [`bootstrap`](https://docs.angularjs.org/api/ng/function/angular.bootstrap) method. Unlike\n * AngularJS v1, this bootstrap is asynchronous.\n *\n * ### Example\n *\n * ```\n * var adapter = new UpgradeAdapter();\n * var module = angular.module('myExample', []);\n * module.directive('ng2', adapter.downgradeNg2Component(Ng2));\n *\n * module.directive('ng1', function() {\n * return {\n * scope: { title: '=' },\n * template: 'ng1[Hello {{title}}!](<span ng-transclude></span>)'\n * };\n * });\n *\n *\n * @Component({\n * selector: 'ng2',\n * inputs: ['name'],\n * template: 'ng2[<ng1 [title]=\"name\">transclude</ng1>](<ng-content></ng-content>)',\n * directives: [adapter.upgradeNg1Component('ng1')]\n * })\n * class Ng2 {\n * }\n *\n * document.body.innerHTML = '<ng2 name=\"World\">project</ng2>';\n *\n * adapter.bootstrap(document.body, ['myExample']).ready(function() {\n * expect(document.body.textContent).toEqual(\n * \"ng2[ng1[Hello World!](transclude)](project)\");\n * });\n * ```\n */\n bootstrap(element: Element, modules?: any[], config?: angular.IAngularBootstrapConfig):\n UpgradeAdapterRef {\n var upgrade = new UpgradeAdapterRef();\n var ng1Injector: angular.IInjectorService = null;\n var platformRef: PlatformRef = browserPlatform();\n var applicationRef: ApplicationRef =\n ReflectiveInjector\n .resolveAndCreate(\n [\n BROWSER_APP_PROVIDERS, BROWSER_APP_COMPILER_PROVIDERS,\n {provide: NG1_INJECTOR, useFactory: () => ng1Injector},\n {provide: NG1_COMPILE, useFactory: () => ng1Injector.get(NG1_COMPILE)},\n this.providers\n ],\n platformRef.injector)\n .get(ApplicationRef);\n var injector: Injector = applicationRef.injector;\n var ngZone: NgZone = injector.get(NgZone);\n var compiler: ComponentResolver = injector.get(ComponentResolver);\n var delayApplyExps: Function[] = [];\n var original$applyFn: Function;\n var rootScopePrototype: any;\n var rootScope: angular.IRootScopeService;\n var componentFactoryRefMap: ComponentFactoryRefMap = {};\n var ng1Module = angular.module(this.idPrefix, modules);\n var ng1BootstrapPromise: Promise<any> = null;\n var ng1compilePromise: Promise<any> = null;\n ng1Module.value(NG2_INJECTOR, injector)\n .value(NG2_ZONE, ngZone)\n .value(NG2_COMPILER, compiler)\n .value(NG2_COMPONENT_FACTORY_REF_MAP, componentFactoryRefMap)\n .config([\n '$provide', '$injector',\n (provide: any /** TODO #???? */, ng1Injector: any /** TODO #???? */) => {\n provide.decorator(NG1_ROOT_SCOPE, [\n '$delegate',\n function(rootScopeDelegate: angular.IRootScopeService) {\n rootScopePrototype = rootScopeDelegate.constructor.prototype;\n if (rootScopePrototype.hasOwnProperty('$apply')) {\n original$applyFn = rootScopePrototype.$apply;\n rootScopePrototype.$apply = (exp: any /** TODO #???? */) =>\n delayApplyExps.push(exp);\n } else {\n throw new Error('Failed to find \\'$apply\\' on \\'$rootScope\\'!');\n }\n return rootScope = rootScopeDelegate;\n }\n ]);\n if (ng1Injector.has(NG1_TESTABILITY)) {\n provide.decorator(NG1_TESTABILITY, [\n '$delegate',\n function(testabilityDelegate: angular.ITestabilityService) {\n var ng2Testability: Testability = injector.get(Testability);\n\n var origonalWhenStable: Function = testabilityDelegate.whenStable;\n var newWhenStable = (callback: Function): void => {\n var whenStableContext: any = this;\n origonalWhenStable.call(this, function() {\n if (ng2Testability.isStable()) {\n callback.apply(this, arguments);\n } else {\n ng2Testability.whenStable(newWhenStable.bind(whenStableContext, callback));\n }\n });\n };\n\n testabilityDelegate.whenStable = newWhenStable;\n return testabilityDelegate;\n }\n ]);\n }\n }\n ]);\n\n ng1compilePromise = new Promise((resolve, reject) => {\n ng1Module.run([\n '$injector', '$rootScope',\n (injector: angular.IInjectorService, rootScope: angular.IRootScopeService) => {\n ng1Injector = injector;\n ngZone.onMicrotaskEmpty.subscribe({\n next: (_: any /** TODO #???? */) =>\n ngZone.runOutsideAngular(() => rootScope.$evalAsync())\n });\n UpgradeNg1ComponentAdapterBuilder.resolve(this.downgradedComponents, injector)\n .then(resolve, reject);\n }\n ]);\n });\n\n // Make sure resumeBootstrap() only exists if the current bootstrap is deferred\n var windowAngular = (window as any /** TODO #???? */)['angular'];\n windowAngular.resumeBootstrap = undefined;\n\n angular.element(element).data(controllerKey(NG2_INJECTOR), injector);\n ngZone.run(() => { angular.bootstrap(element, [this.idPrefix], config); });\n ng1BootstrapPromise = new Promise((resolve, reject) => {\n if (windowAngular.resumeBootstrap) {\n var originalResumeBootstrap: () => void = windowAngular.resumeBootstrap;\n windowAngular.resumeBootstrap = function() {\n windowAngular.resumeBootstrap = originalResumeBootstrap;\n windowAngular.resumeBootstrap.apply(this, arguments);\n resolve();\n };\n } else {\n resolve();\n }\n });\n\n Promise\n .all([\n this.compileNg2Components(compiler, componentFactoryRefMap), ng1BootstrapPromise,\n ng1compilePromise\n ])\n .then(() => {\n ngZone.run(() => {\n if (rootScopePrototype) {\n rootScopePrototype.$apply = original$applyFn; // restore original $apply\n while (delayApplyExps.length) {\n rootScope.$apply(delayApplyExps.shift());\n }\n (<any>upgrade)._bootstrapDone(applicationRef, ng1Injector);\n rootScopePrototype = null;\n }\n });\n }, onError);\n return upgrade;\n }\n\n /**\n * Adds a provider to the top level environment of a hybrid AngularJS v1 / Angular v2 application.\n *\n * In hybrid AngularJS v1 / Angular v2 application, there is no one root Angular v2 component,\n * for this reason we provide an application global way of registering providers which is\n * consistent with single global injection in AngularJS v1.\n *\n * ### Example\n *\n * ```\n * class Greeter {\n * greet(name) {\n * alert('Hello ' + name + '!');\n * }\n * }\n *\n * @Component({\n * selector: 'app',\n * template: ''\n * })\n * class App {\n * constructor(greeter: Greeter) {\n * this.greeter('World');\n * }\n * }\n *\n * var adapter = new UpgradeAdapter();\n * adapter.addProvider(Greeter);\n *\n * var module = angular.module('myExample', []);\n * module.directive('app', adapter.downgradeNg2Component(App));\n *\n * document.body.innerHTML = '<app></app>'\n * adapter.bootstrap(document.body, ['myExample']);\n *```\n */\n public addProvider(provider: Type|Provider|any[]|any): void { this.providers.push(provider); }\n\n /**\n * Allows AngularJS v1 service to be accessible from Angular v2.\n *\n *\n * ### Example\n *\n * ```\n * class Login { ... }\n * class Server { ... }\n *\n * @Injectable()\n * class Example {\n * constructor(@Inject('server') server, login: Login) {\n * ...\n * }\n * }\n *\n * var module = angular.module('myExample', []);\n * module.service('server', Server);\n * module.service('login', Login);\n *\n * var adapter = new UpgradeAdapter();\n * adapter.upgradeNg1Provider('server');\n * adapter.upgradeNg1Provider('login', {asToken: Login});\n * adapter.addProvider(Example);\n *\n * adapter.bootstrap(document.body, ['myExample']).ready((ref) => {\n * var example: Example = ref.ng2Injector.get(Example);\n * });\n *\n * ```\n */\n public upgradeNg1Provider(name: string, options?: {asToken: any}) {\n var token = options && options.asToken || name;\n this.providers.push({\n provide: token,\n useFactory: (ng1Injector: angular.IInjectorService) => ng1Injector.get(name),\n deps: [NG1_INJECTOR]\n });\n }\n\n /**\n * Allows Angular v2 service to be accessible from AngularJS v1.\n *\n *\n * ### Example\n *\n * ```\n * class Example {\n * }\n *\n * var adapter = new UpgradeAdapter();\n * adapter.addProvider(Example);\n *\n * var module = angular.module('myExample', []);\n * module.factory('example', adapter.downgradeNg2Provider(Example));\n *\n * adapter.bootstrap(document.body, ['myExample']).ready((ref) => {\n * var example: Example = ref.ng1Injector.get('example');\n * });\n *\n * ```\n */\n public downgradeNg2Provider(token: any): Function {\n var factory = function(injector: Injector) { return injector.get(token); };\n (<any>factory).$inject = [NG2_INJECTOR];\n return factory;\n }\n\n /* @internal */\n private compileNg2Components(\n compiler: ComponentResolver,\n componentFactoryRefMap: ComponentFactoryRefMap): Promise<ComponentFactoryRefMap> {\n var promises: Array<Promise<ComponentFactory<any>>> = [];\n var types = this.upgradedComponents;\n for (var i = 0; i < types.length; i++) {\n promises.push(compiler.resolveComponent(types[i]));\n }\n return Promise.all(promises).then((componentFactories: Array<ComponentFactory<any>>) => {\n var types = this.upgradedComponents;\n for (var i = 0; i < componentFactories.length; i++) {\n componentFactoryRefMap[getComponentInfo(types[i]).selector] = componentFactories[i];\n }\n return componentFactoryRefMap;\n }, onError);\n }\n}\n\ninterface ComponentFactoryRefMap {\n [selector: string]: ComponentFactory<any>;\n}\n\nfunction ng1ComponentDirective(info: ComponentInfo, idPrefix: string): Function {\n (<any>directiveFactory).$inject = [NG1_INJECTOR, NG2_COMPONENT_FACTORY_REF_MAP, NG1_PARSE];\n function directiveFactory(\n ng1Injector: angular.IInjectorService, componentFactoryRefMap: ComponentFactoryRefMap,\n parse: angular.IParseService): angular.IDirective {\n var idCount = 0;\n return {\n restrict: 'E',\n require: REQUIRE_INJECTOR,\n link: {\n post: (scope: angular.IScope, element: angular.IAugmentedJQuery, attrs: angular.IAttributes,\n parentInjector: any, transclude: angular.ITranscludeFunction): void => {\n var componentFactory: ComponentFactory<any> = componentFactoryRefMap[info.selector];\n if (!componentFactory)\n throw new Error('Expecting ComponentFactory for: ' + info.selector);\n\n var domElement = <any>element[0];\n if (parentInjector === null) {\n parentInjector = ng1Injector.get(NG2_INJECTOR);\n }\n var facade = new DowngradeNg2ComponentAdapter(\n idPrefix + (idCount++), info, element, attrs, scope, <Injector>parentInjector, parse,\n componentFactory);\n facade.setupInputs();\n facade.bootstrapNg2();\n facade.projectContent();\n facade.setupOutputs();\n facade.registerCleanup();\n }\n }\n };\n }\n return directiveFactory;\n}\n\n/**\n * Use `UgradeAdapterRef` to control a hybrid AngularJS v1 / Angular v2 application.\n */\nexport class UpgradeAdapterRef {\n /* @internal */\n private _readyFn: (upgradeAdapterRef?: UpgradeAdapterRef) => void = null;\n\n public ng1RootScope: angular.IRootScopeService = null;\n public ng1Injector: angular.IInjectorService = null;\n public ng2ApplicationRef: ApplicationRef = null;\n public ng2Injector: Injector = null;\n\n /* @internal */\n private _bootstrapDone(applicationRef: ApplicationRef, ng1Injector: angular.IInjectorService) {\n this.ng2ApplicationRef = applicationRef;\n this.ng2Injector = applicationRef.injector;\n this.ng1Injector = ng1Injector;\n this.ng1RootScope = ng1Injector.get(NG1_ROOT_SCOPE);\n this._readyFn && this._readyFn(this);\n }\n\n /**\n * Register a callback function which is notified upon successful hybrid AngularJS v1 / Angular v2\n * application has been bootstrapped.\n *\n * The `ready` callback function is invoked inside the Angular v2 zone, therefore it does not\n * require a call to `$apply()`.\n */\n public ready(fn: (upgradeAdapterRef?: UpgradeAdapterRef) => void) { this._readyFn = fn; }\n\n /**\n * Dispose of running hybrid AngularJS v1 / Angular v2 application.\n */\n public dispose() {\n this.ng1Injector.get(NG1_ROOT_SCOPE).$destroy();\n this.ng2ApplicationRef.dispose();\n }\n}\n\ninterface DecoratorInvocation {\n type: Function;\n args?: any[];\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var core_1 = require('@angular/core');
|
|
3
|
+
var angular = require('./angular_js');
|
|
3
4
|
var constants_1 = require('./constants');
|
|
4
5
|
var util_1 = require('./util');
|
|
5
|
-
var angular = require('./angular_js');
|
|
6
6
|
var CAMEL_CASE = /([A-Z])/g;
|
|
7
7
|
var INITIAL_VALUE = {
|
|
8
8
|
__UNINITIALIZED__: true
|
|
@@ -21,14 +21,13 @@ var UpgradeNg1ComponentAdapterBuilder = (function () {
|
|
|
21
21
|
this.linkFn = null;
|
|
22
22
|
this.directive = null;
|
|
23
23
|
this.$controller = null;
|
|
24
|
-
var selector = name.replace(CAMEL_CASE, function (all
|
|
24
|
+
var selector = name.replace(CAMEL_CASE, function (all /** TODO #9100 */, next) { return '-' + next.toLowerCase(); });
|
|
25
25
|
var self = this;
|
|
26
26
|
this.type =
|
|
27
27
|
core_1.Directive({ selector: selector, inputs: this.inputsRename, outputs: this.outputsRename })
|
|
28
28
|
.Class({
|
|
29
29
|
constructor: [
|
|
30
|
-
new core_1.Inject(constants_1.NG1_SCOPE),
|
|
31
|
-
core_1.ElementRef,
|
|
30
|
+
new core_1.Inject(constants_1.NG1_SCOPE), core_1.ElementRef,
|
|
32
31
|
function (scope, elementRef) {
|
|
33
32
|
return new UpgradeNg1ComponentAdapter(self.linkFn, scope, self.directive, elementRef, self.$controller, self.inputs, self.outputs, self.propertyOutputs, self.checkProperties, self.propertyMap);
|
|
34
33
|
}
|
|
@@ -106,17 +105,19 @@ var UpgradeNg1ComponentAdapterBuilder = (function () {
|
|
|
106
105
|
UpgradeNg1ComponentAdapterBuilder.prototype.compileTemplate = function (compile, templateCache, httpBackend) {
|
|
107
106
|
var _this = this;
|
|
108
107
|
if (this.directive.template !== undefined) {
|
|
109
|
-
this.linkFn = compileHtml(this.directive.template)
|
|
108
|
+
this.linkFn = compileHtml(typeof this.directive.template === 'function' ? this.directive.template() :
|
|
109
|
+
this.directive.template);
|
|
110
110
|
}
|
|
111
111
|
else if (this.directive.templateUrl) {
|
|
112
|
-
var url = this.directive.templateUrl
|
|
112
|
+
var url = typeof this.directive.templateUrl === 'function' ? this.directive.templateUrl() :
|
|
113
|
+
this.directive.templateUrl;
|
|
113
114
|
var html = templateCache.get(url);
|
|
114
115
|
if (html !== undefined) {
|
|
115
116
|
this.linkFn = compileHtml(html);
|
|
116
117
|
}
|
|
117
118
|
else {
|
|
118
119
|
return new Promise(function (resolve, err) {
|
|
119
|
-
httpBackend('GET', url, null, function (status
|
|
120
|
+
httpBackend('GET', url, null, function (status /** TODO #9100 */, response /** TODO #9100 */) {
|
|
120
121
|
if (status == 200) {
|
|
121
122
|
resolve(_this.linkFn = compileHtml(templateCache.put(url, response)));
|
|
122
123
|
}
|
|
@@ -131,7 +132,7 @@ var UpgradeNg1ComponentAdapterBuilder = (function () {
|
|
|
131
132
|
throw new Error("Directive '" + this.name + "' is not a component, it is missing template.");
|
|
132
133
|
}
|
|
133
134
|
return null;
|
|
134
|
-
function compileHtml(html) {
|
|
135
|
+
function compileHtml(html /** TODO #9100 */) {
|
|
135
136
|
var div = document.createElement('div');
|
|
136
137
|
div.innerHTML = html;
|
|
137
138
|
return compile(div.childNodes);
|
|
@@ -163,6 +164,7 @@ var UpgradeNg1ComponentAdapter = (function () {
|
|
|
163
164
|
function UpgradeNg1ComponentAdapter(linkFn, scope, directive, elementRef, $controller, inputs, outputs, propOuts, checkProperties, propertyMap) {
|
|
164
165
|
this.linkFn = linkFn;
|
|
165
166
|
this.directive = directive;
|
|
167
|
+
this.$controller = $controller;
|
|
166
168
|
this.inputs = inputs;
|
|
167
169
|
this.outputs = outputs;
|
|
168
170
|
this.propOuts = propOuts;
|
|
@@ -170,33 +172,25 @@ var UpgradeNg1ComponentAdapter = (function () {
|
|
|
170
172
|
this.propertyMap = propertyMap;
|
|
171
173
|
this.destinationObj = null;
|
|
172
174
|
this.checkLastValues = [];
|
|
175
|
+
this.$element = null;
|
|
173
176
|
this.element = elementRef.nativeElement;
|
|
174
177
|
this.componentScope = scope.$new(!!directive.scope);
|
|
175
|
-
|
|
178
|
+
this.$element = angular.element(this.element);
|
|
176
179
|
var controllerType = directive.controller;
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
var locals = { $scope: this.componentScope, $element: $element };
|
|
180
|
-
controller = $controller(controllerType, locals, null, directive.controllerAs);
|
|
181
|
-
$element.data(util_1.controllerKey(directive.name), controller);
|
|
180
|
+
if (directive.bindToController && controllerType) {
|
|
181
|
+
this.destinationObj = this.buildController(controllerType);
|
|
182
182
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
link = link.pre;
|
|
186
|
-
if (link) {
|
|
187
|
-
var attrs = NOT_SUPPORTED;
|
|
188
|
-
var transcludeFn = NOT_SUPPORTED;
|
|
189
|
-
var linkController = this.resolveRequired($element, directive.require);
|
|
190
|
-
directive.link(this.componentScope, $element, attrs, linkController, transcludeFn);
|
|
183
|
+
else {
|
|
184
|
+
this.destinationObj = this.componentScope;
|
|
191
185
|
}
|
|
192
|
-
this.destinationObj =
|
|
193
|
-
directive.bindToController && controller ? controller : this.componentScope;
|
|
194
186
|
for (var i = 0; i < inputs.length; i++) {
|
|
195
187
|
this[inputs[i]] = null;
|
|
196
188
|
}
|
|
197
189
|
for (var j = 0; j < outputs.length; j++) {
|
|
198
190
|
var emitter = this[outputs[j]] = new core_1.EventEmitter();
|
|
199
|
-
this.setComponentProperty(outputs[j], (function (emitter) { return function (value
|
|
191
|
+
this.setComponentProperty(outputs[j], (function (emitter /** TODO #9100 */) { return function (value /** TODO #9100 */) {
|
|
192
|
+
return emitter.emit(value);
|
|
193
|
+
}; })(emitter));
|
|
200
194
|
}
|
|
201
195
|
for (var k = 0; k < propOuts.length; k++) {
|
|
202
196
|
this[propOuts[k]] = new core_1.EventEmitter();
|
|
@@ -205,6 +199,18 @@ var UpgradeNg1ComponentAdapter = (function () {
|
|
|
205
199
|
}
|
|
206
200
|
UpgradeNg1ComponentAdapter.prototype.ngOnInit = function () {
|
|
207
201
|
var _this = this;
|
|
202
|
+
if (!this.directive.bindToController && this.directive.controller) {
|
|
203
|
+
this.buildController(this.directive.controller);
|
|
204
|
+
}
|
|
205
|
+
var link = this.directive.link;
|
|
206
|
+
if (typeof link == 'object')
|
|
207
|
+
link = link.pre;
|
|
208
|
+
if (link) {
|
|
209
|
+
var attrs = NOT_SUPPORTED;
|
|
210
|
+
var transcludeFn = NOT_SUPPORTED;
|
|
211
|
+
var linkController = this.resolveRequired(this.$element, this.directive.require);
|
|
212
|
+
this.directive.link(this.componentScope, this.$element, attrs, linkController, transcludeFn);
|
|
213
|
+
}
|
|
208
214
|
var childNodes = [];
|
|
209
215
|
var childNode;
|
|
210
216
|
while (childNode = this.element.firstChild) {
|
|
@@ -215,7 +221,9 @@ var UpgradeNg1ComponentAdapter = (function () {
|
|
|
215
221
|
for (var i = 0, ii = clonedElement.length; i < ii; i++) {
|
|
216
222
|
_this.element.appendChild(clonedElement[i]);
|
|
217
223
|
}
|
|
218
|
-
}, {
|
|
224
|
+
}, {
|
|
225
|
+
parentBoundTranscludeFn: function (scope /** TODO #9100 */, cloneAttach /** TODO #9100 */) { cloneAttach(childNodes); }
|
|
226
|
+
});
|
|
219
227
|
if (this.destinationObj.$onInit) {
|
|
220
228
|
this.destinationObj.$onInit();
|
|
221
229
|
}
|
|
@@ -250,6 +258,12 @@ var UpgradeNg1ComponentAdapter = (function () {
|
|
|
250
258
|
UpgradeNg1ComponentAdapter.prototype.setComponentProperty = function (name, value) {
|
|
251
259
|
this.destinationObj[this.propertyMap[name]] = value;
|
|
252
260
|
};
|
|
261
|
+
UpgradeNg1ComponentAdapter.prototype.buildController = function (controllerType /** TODO #9100 */) {
|
|
262
|
+
var locals = { $scope: this.componentScope, $element: this.$element };
|
|
263
|
+
var controller = this.$controller(controllerType, locals, null, this.directive.controllerAs);
|
|
264
|
+
this.$element.data(util_1.controllerKey(this.directive.name), controller);
|
|
265
|
+
return controller;
|
|
266
|
+
};
|
|
253
267
|
UpgradeNg1ComponentAdapter.prototype.resolveRequired = function ($element, require) {
|
|
254
268
|
if (!require) {
|
|
255
269
|
return undefined;
|