'), ['myExample']).ready((ref) => {
expect(ref.ng1Injector.get('someToken')).toBe('correct_value');
@@ -943,11 +944,11 @@ export function main() {
}));
it('should export ng1 instance to ng2', async(() => {
- var MyNg2Module =
+ const MyNg2Module =
NgModule({imports: [BrowserModule]}).Class({constructor: function() {}});
const adapter: UpgradeAdapter = new UpgradeAdapter(MyNg2Module);
- var module = angular.module('myExample', []);
+ const module = angular.module('myExample', []);
module.value('testValue', 'secreteToken');
adapter.upgradeNg1Provider('testValue');
adapter.upgradeNg1Provider('testValue', {asToken: 'testToken'});
@@ -963,14 +964,14 @@ export function main() {
describe('testability', () => {
it('should handle deferred bootstrap', async(() => {
- var MyNg2Module =
+ const MyNg2Module =
NgModule({imports: [BrowserModule]}).Class({constructor: function() {}});
const adapter: UpgradeAdapter = new UpgradeAdapter(MyNg2Module);
angular.module('ng1', []);
- var bootstrapResumed: boolean = false;
+ let bootstrapResumed: boolean = false;
- var element = html('
');
+ const element = html('
');
window.name = 'NG_DEFER_BOOTSTRAP!' + window.name;
adapter.bootstrap(element, ['ng1']).ready((ref) => {
@@ -985,18 +986,18 @@ export function main() {
}));
it('should wait for ng2 testability', async(() => {
- var MyNg2Module =
+ const MyNg2Module =
NgModule({imports: [BrowserModule]}).Class({constructor: function() {}});
const adapter: UpgradeAdapter = new UpgradeAdapter(MyNg2Module);
angular.module('ng1', []);
- var element = html('
');
+ const element = html('
');
adapter.bootstrap(element, ['ng1']).ready((ref) => {
- var ng2Testability: Testability = ref.ng2Injector.get(Testability);
+ const ng2Testability: Testability = ref.ng2Injector.get(Testability);
ng2Testability.increasePendingRequestCount();
- var ng2Stable = false;
+ let ng2Stable = false;
- angular.getTestability(element).whenStable(function() {
+ angular.getTestability(element).whenStable(() => {
expect(ng2Stable).toEqual(true);
ref.dispose();
});
@@ -1011,7 +1012,7 @@ export function main() {
it('should allow attribute selectors for components in ng2', async(() => {
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => MyNg2Module));
- var ng1Module = angular.module('myExample', []);
+ const ng1Module = angular.module('myExample', []);
@Component({selector: '[works]', template: 'works!'})
class WorksComponent {
@@ -1037,28 +1038,29 @@ export function main() {
describe('examples', () => {
it('should verify UpgradeAdapter example', async(() => {
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
- var module = angular.module('myExample', []);
+ const module = angular.module('myExample', []);
- module.directive('ng1', function() {
+ const ng1 = () => {
return {
scope: {title: '='},
transclude: true,
template: 'ng1[Hello {{title}}!](
)'
};
- });
+ };
+ module.directive('ng1', ng1);
- var Ng2 =
+ const Ng2 =
Component({
selector: 'ng2',
inputs: ['name'],
template: 'ng2[
transclude](
)'
}).Class({constructor: function() {}});
- var Ng2Module = NgModule({
- declarations: [adapter.upgradeNg1Component('ng1'), Ng2],
- imports: [BrowserModule],
- schemas: [NO_ERRORS_SCHEMA],
- }).Class({constructor: function() {}});
+ const Ng2Module = NgModule({
+ declarations: [adapter.upgradeNg1Component('ng1'), Ng2],
+ imports: [BrowserModule],
+ schemas: [NO_ERRORS_SCHEMA],
+ }).Class({constructor: function() {}});
module.directive('ng2', adapter.downgradeNg2Component(Ng2));
@@ -1079,7 +1081,7 @@ function multiTrim(text: string): string {
}
function html(html: string): Element {
- var body = document.body;
+ const body = document.body;
body.innerHTML = html;
if (body.childNodes.length == 1 && body.firstChild instanceof HTMLElement)
return
body.firstChild;