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.

NbWindowService - context no longer works

See original GitHub issue

Issue type

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

  • bug report
  • feature request

Issue description

Current behavior:

I just upgraded from 3.0.0 to 3.3.0, and now the context property no longer works when creating a window.

It appears the example app/demo is not working either: https://akveo.github.io/nebular/example/window/template-window.component

Expected behavior:

When passing in an object as the context, I would expect my component to have access to that data, according to the docs: “For components, this data will be set as component properties.”

Steps to reproduce:

Pass a context property to the configuration of a window.

Related code:

The code below works on 3.0.0, but after the upgrade it doesn’t work:

parent.component.ts:
this.windowService.open(MyComponent,
      { title: 'Details', context: { records: row.data} }
    );

my.component.ts:
  ngOnInit() {
  // should output data
    console.log(this.records);
  }

Other information:

npm, node, OS, Browser

npm 5.6.0

Angular, Nebular

    "@angular/cdk": "^7.2.1",
    "@angular/common": "^7.2.1",
    "@angular/compiler": "^7.2.1",
    "@angular/core": "^7.2.1",
    "@angular/forms": "^7.2.1",
    "@angular/http": "^7.2.1",
    "@nebular/auth": "3.3.0",
    "@nebular/bootstrap": "3.3.0",
    "@nebular/security": "3.3.0",
    "@nebular/theme": "3.3.0",

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
ygggcommented, Apr 14, 2019

Thanks, @swbradshaw. So the issue is that context is set after window component was initialized, right? We’ll look into this. As a workaround, for now, you can inject window context using NB_WINDOW_CONTEXT injection token. This way it will be available right off.

import { NB_WINDOW_CONTEXT } from '@nebular/theme/components/window/window.options';
//...
class MyComponent {
  text: string;

  constructor(@Inject(NB_WINDOW_CONTEXT) context) {
    this.text = context.text;
  }
}
2reactions
swbradshawcommented, Mar 30, 2019

I just tested this fix on 3.4.1, and it does not work.

If I setup breakpoints in the code, I can see that NbWindowService.prototype.appendWindow calls ref.changeDetectorRef.detectChanges(); but the code never continues; a breakpoint on the next line return ref; is never hit. When the window launches my component, I have a breakpoint in ngOnInit, and the context object is missing. It seems like the Window component doesn’t attach until the ngAfterViewChecked life cycle, which is well after the component has done its init.

Downgrading back to an older version again.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I reference the component's instance of a NbWindow
windowService's open() method accepts a context object that can be injected in the target window component, so we can use it to make...
Read more >
Window Angular UI Component - Nebular - GitHub Pages
The NbWindowService can be used to open windows. Showcase ... Also you can get reference to the NbWindowRef in context's windowRef property.
Read more >
Setting Nebular Modal Size: My Approach - Leonel Elimpe
... with this setup however the modal has the tendency to not adjust ... I've had a look at the bootstrap modal (which...
Read more >
Box Remaining On Screen In Windows 10/8/7 FIX - YouTube
Right Click Context Menu Not Disappearing - Box Remaining On Screen In Windows 10/8/7 FIX. This error which causes the context menu (or...
Read more >
How to use NbWindowService in nebular to open a form in another ...
But it does not show the content in the .html file in 'FormComponent'. Can anyone show me the place where I have gone...
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