Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(modal): implicit context for template based modal #2669

Closed

Conversation

benouat
Copy link
Member

@benouat benouat commented Aug 30, 2018

Any template based modal should now be using implicit context

Before:

<ng-template #content let-c="close" let-d="dismiss">
  <!-- ... -->
  <button (click)="c('closing')">Close</button>
  <button (click)="d('dismiss')">Dismiss</button>
  <!-- ... -->
</ng-template>

After:

<ng-template #content let-modal>
  <!-- ... -->
  <button (click)="modal.close('closing')">Close</button>
  <button (click)="modal.dismiss('dismiss')">Dismiss</button>
  <!-- ... -->
</ng-template>

@benouat benouat changed the title fix(modal): implicit context for template based fix(modal): implicit context for template based modal Aug 30, 2018
@@ -132,7 +131,9 @@ export class NgbModalStack {
}

private _createFromTemplateRef(content: TemplateRef<any>, context: NgbActiveModal): ContentRef {
const viewRef = content.createEmbeddedView(context);
const $context =
{$implicit: context, close(result) { context.close(result); }, dismiss(reason) { context.dismiss(reason); }};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please rename:

  • context => activeModal
  • $context => tplRefContext / context

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -26,7 +26,7 @@ class CustomSpyService {
called = false;
}

describe('ngb-modal', () => {
fdescribe('ngb-modal', () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fdescribe

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@benouat benouat changed the title fix(modal): implicit context for template based modal feat(modal): implicit context for template based modal Aug 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants