question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error when performing AOT build: Property 'escapeKeyboardEvent' is private

See original GitHub issue

I’m submitting a … (check one with “x”)

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter

Current behavior

When performing an AOT build, I get the following error.

ERROR in (1,1): : Directive NgxSmartModalComponent, Property 'escapeKeyboardEvent' is private and only accessible within class 'NgxSmartModalComponent'.
ClientApp\app\public\productdetails\productdetails.component.html(56,1): : Directive NgxSmartModalComponent, Property 'escapeKeyboardEvent' is private and only accessible within class 'NgxSmartModalComponent'.

Expected behavior

I was expecting to be able to do AOT build.

Reproduction of the problem

Content of component HTML template

<!-- ... -->
<ngx-smart-modal #classicModal identifier="classicModal">
  <h1>Hey, I'm a simple modal!</h1>
  <img class="modal-image" src="http://lorempicsum.com/futurama/627/200/3" alt="Lorem picsum">
  <p>{{ "sampleText[0]" }}</p>
  <button class="button -dark" (click)="classicModal.close()">Close</button>
</ngx-smart-modal>

Content of app module

  // ...
  imports: [
    BrowserModule,
    HttpClientModule,
    FormsModule,
    ReactiveFormsModule,
    NgxSmartModalModule.forRoot(),
    // ....
  ]
  // ...

Please tell us about your environment:

  • Windows 10 Enterprise

  • Smart Modal version: 6.0.2

  • Angular version: 5.2.10
  • Browser: N/A

  • Language: TypeScript 2.5.3

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
matthewdunsdoncommented, May 31, 2018

In ngx-smart-modal.component.ts#L183-L184, I see the following:

  @HostListener('document:keyup', ['$event'])
  private escapeKeyboardEvent(event: KeyboardEvent) {

Question to consider …

  • Is is valid to use a @HostListener annotation on a private method?

Angular AOT does care & check whether fields / properties /methods are private, both when checking component html templates and on usage (i.e. by library consumers like myself 🗣 ).

0reactions
maximelafariecommented, Jun 4, 2018

Yep, you’re right @matthewdunsdon, I’ll fix that! 👌

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error when performing AOT build: Property ... - GitHub
ERROR in (1,1): : Directive NgxSmartModalComponent, Property 'escapeKeyboardEvent' is private and only accessible within class ...
Read more >
Angular AOT build failing because of Private member
Accessing private members is an error and so you should fix it. Solution: Make the property public. Every other solution I can imagine...
Read more >
AoT compiles even when templates are accessing private ...
I came across this situation where I have a component with private fields, which are accessed in my template, but still the build...
Read more >
Angular: Writing AoT-friendly applications | by David - Medium
Now, when running ng build --prod again, another error shows up: Property '{xyz}' is private and only accessible within class '{component}'.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found