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

Access to component context through Output ? #40

Closed
raphael22 opened this issue Dec 19, 2016 · 2 comments
Closed

Access to component context through Output ? #40

raphael22 opened this issue Dec 19, 2016 · 2 comments
Milestone

Comments

@raphael22
Copy link

Issue : Could not access to my component variables on after-load callback function.

// my-component.ts
onLoaded(pdf) {
  this.loading = false // <- loading unknown
}

Proposal: Use Output instead of Input with pdf as return value.

// pdf-viewer.component.ts
@Output() afterLoadCompleteEmitter = new EventEmitter()
...
if (this.afterLoadComplete && typeof this.afterLoadComplete === 'function') {
  this.afterLoadComplete(pdf);
}
...
afterLoadComplete(pdf) {
  this.afterLoadCompleteEmitter.emit({ value: pdf })
}


// my.component.html
<pdf-viewer [src]="selected.value"
            (afterLoadComplete)="onLoaded($event)"
            [show-all]="true"
            [page]="1" 
            [original-size]="true">
</pdf-viewer>

// my-component.ts
onLoaded(event) {
  const pdf = event.value
  this.loading = false // <- loading known
}
@raphael22
Copy link
Author

I've just see your binding in src example.

    this.afterLoadComplete = this.afterLoadComplete.bind(this);

But Output wouldn't be a better workaround ?

@VadimDez
Copy link
Owner

Resolved by #47

@VadimDez VadimDez added this to the 1.0.0 milestone Jan 23, 2017
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

No branches or pull requests

2 participants