diff --git a/src/app/compiler/angular/deps/directive-dep.factory.ts b/src/app/compiler/angular/deps/directive-dep.factory.ts index 9ec2bf3f..370d9273 100644 --- a/src/app/compiler/angular/deps/directive-dep.factory.ts +++ b/src/app/compiler/angular/deps/directive-dep.factory.ts @@ -21,6 +21,7 @@ export class DirectiveDepFactory { sourceCode: srcFile.getText(), selector: this.helper.getComponentSelector(props, srcFile), providers: this.helper.getComponentProviders(props, srcFile), + exportAs: this.helper.getComponentExportAs(props, srcFile), inputsClass: IO.inputs, outputsClass: IO.outputs, @@ -65,6 +66,7 @@ export interface IDirectiveDep extends IDep { selector: string; providers: Array; + exportAs: string; inputsClass: any; outputsClass: any; diff --git a/src/templates/partials/directive.hbs b/src/templates/partials/directive.hbs index 16c51906..3567e699 100644 --- a/src/templates/partials/directive.hbs +++ b/src/templates/partials/directive.hbs @@ -104,6 +104,13 @@ {{/if}} + {{#if directive.exportAs}} + + {{t "exportAs" }} + {{directive.exportAs}} + + {{/if}} + diff --git a/test/fixtures/todomvc-ng2/src/app/shared/directives/do-nothing-directive.metadata.ts b/test/fixtures/todomvc-ng2/src/app/shared/directives/do-nothing-directive.metadata.ts index 63f68e81..d8fd652e 100644 --- a/test/fixtures/todomvc-ng2/src/app/shared/directives/do-nothing-directive.metadata.ts +++ b/test/fixtures/todomvc-ng2/src/app/shared/directives/do-nothing-directive.metadata.ts @@ -1,3 +1,4 @@ export const DoNothingDirectiveSchema = { - selector: '[donothing]' + selector: '[donothing]', + exportAs: 'donothing' }; diff --git a/test/src/cli/cli-generation-big-app.spec.ts b/test/src/cli/cli-generation-big-app.spec.ts index 15f132ab..c1a6147b 100644 --- a/test/src/cli/cli-generation-big-app.spec.ts +++ b/test/src/cli/cli-generation-big-app.spec.ts @@ -924,4 +924,9 @@ describe('CLI simple generation - big app', () => { const file = read(distFolder + '/modules/FooterModule.html'); expect(file).to.contain('href="../injectables/EmitterService.html">EmitterService'); }); + + it('should support exportAs for directives', () => { + const file = read(distFolder + '/directives/DoNothingDirective.html'); + expect(file).to.contain('donothing'); + }); });