Skip to content

Instantly share code, notes, and snippets.

@shumbo
Created December 24, 2016 23:38
Show Gist options
  • Save shumbo/73400ee836c2bf4b977c4f4badbfadee to your computer and use it in GitHub Desktop.
Save shumbo/73400ee836c2bf4b977c4f4badbfadee to your computer and use it in GitHub Desktop.
import {
Injectable,
ViewContainerRef,
Component,
ViewChild,
Directive,
AfterViewInit
} from '@angular/core';
import { Modal } from './modal.service';
@Directive({
selector: '[appModalInner]',
})
export class ModalInnerDirective {
constructor(public vcr: ViewContainerRef) {
}
}
@Component({
selector: 'app-modal-entry',
template: `
<div class='bg' [class.active]="modal.isShow()">
<div appModalInner></div>
</div>
`,
providers: [ModalInnerDirective],
})
export class ModalEntryComponent implements AfterViewInit {
@ViewChild(ModalInnerDirective) private inner: ModalInnerDirective;
constructor(
public modal: Modal
) {
}
ngAfterViewInit() {
this.modal.vcr = this.inner.vcr;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment