diff --git a/modules/angular2/src/upgrade/upgrade_ng1_adapter.ts b/modules/angular2/src/upgrade/upgrade_ng1_adapter.ts index d6a7136ba3..5d9a4b7504 100644 --- a/modules/angular2/src/upgrade/upgrade_ng1_adapter.ts +++ b/modules/angular2/src/upgrade/upgrade_ng1_adapter.ts @@ -120,7 +120,7 @@ export class UpgradeNg1ComponentAdapterBuilder { compileTemplate(compile: angular.ICompileService, templateCache: angular.ITemplateCacheService, httpBackend: angular.IHttpBackendService): Promise { - if (this.directive.template) { + if (this.directive.template !== undefined) { this.linkFn = compileHtml(this.directive.template); } else if (this.directive.templateUrl) { var url = this.directive.templateUrl; diff --git a/modules/angular2/test/upgrade/upgrade_spec.ts b/modules/angular2/test/upgrade/upgrade_spec.ts index 26c11fb1ec..c22dc9f676 100644 --- a/modules/angular2/test/upgrade/upgrade_spec.ts +++ b/modules/angular2/test/upgrade/upgrade_spec.ts @@ -304,6 +304,27 @@ export function main() { }); })); + it('should support empty template', inject([AsyncTestCompleter], (async) => { + var adapter = new UpgradeAdapter(); + var ng1Module = angular.module('ng1', []); + + var ng1 = function() { return {template: ''}; }; + ng1Module.directive('ng1', ng1); + var Ng2 = Component({ + selector: 'ng2', + template: '', + directives: [adapter.upgradeNg1Component('ng1')] + }).Class({constructor: function() {}}); + ng1Module.directive('ng2', adapter.downgradeNg2Component(Ng2)); + var element = html(`
`); + adapter.bootstrap(element, ['ng1']) + .ready((ref) => { + expect(multiTrim(document.body.textContent)).toEqual(''); + ref.dispose(); + async.done(); + }); + })); + it('should support templateUrl fetched from $templateCache', inject([AsyncTestCompleter], (async) => { var adapter = new UpgradeAdapter();