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.

Pass data to ViewRef resulting from TemplateRef content

See original GitHub issue

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

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

Current behavior Currently, there’s no way to set the context of the view when passing a TemplateRef to NgxSmartModalService.create.

Expected behavior The context of the ViewRef should be sync with the data of the modal.

Reproduction of the problem Example use case here: https://stackblitz.com/edit/ngx-smart-modal-example-4vbtak

What is the motivation / use case for changing the behavior? I need this because I cannot scope the ngx-smart-modal component inside the part of the component that have access to my data, and that is refreshed regularly. So, I need to be able to inject data from anywhere, in a template, and use let-foo to get the foo context property.

Please tell us about your environment: In a poor condition 🌲 🔥

  • Smart Modal version: 7.3.0

  • Angular version: 8.2.13

  • Browser: all

  • Language: TypeScript


Possible implementation Setting the context of the EmbeddedViewRef created in NgxSmartModalService works (I just tried). So the EmbeddedViewRef reference should be stored somewhere to be reused when calling NgxSmartModalService.setData.

I can PR 🍻

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
LouisAugrycommented, Jan 27, 2020

Can you try again locally with the latest version of master please. @maximelafarie fixed this problem I think

0reactions
GerkinDevcommented, Jan 28, 2020

I found a way of doing what I want using the new examples mentioned above. But I still think setting arbitrary context can be useful.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pass data to ViewRef resulting from TemplateRef content #268
Current behavior. Currently, there's no way to set the context of the view when passing a TemplateRef to NgxSmartModalService.create .
Read more >
angular - Getting content of dynamic templates in component
When I am logging 'viewRef.rootNodes', I could see the static text 'hello' but the dynamic text 'angular' which I am passing through implicit ......
Read more >
Angular ElementRef, TemplateRef, and ViewContainerRef ...
An overview of ElementRef, TemplateRef, ViewRef, and ViewContainerRef in Angular and how to modify the DOM programmatically. Read to learn more.
Read more >
Using TemplateRef and ngTemplateOutlet To Pass Templates ...
While it may seem simple, simply pass through a string variable with HTML inside and be done with it, when it comes to...
Read more >
TemplateRef - Angular
Represents an embedded template that can be used to instantiate embedded views. To instantiate embedded views based on a template, use the ViewContainerRef ......
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