-
Notifications
You must be signed in to change notification settings - Fork 222
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
feat(popup): Accessing context variables from within popup template #127
Comments
Have you tried defining the <div *ngFor="let item of items">
<ng-template #template>
<p>{{ item.name }}</p>
</ng-template>
<button class="ui button" suiPopup [popupTemplate]="template">Action</button>
</div> |
Just made a plunkr demonstrating this - does that suit your use case? |
Ok @edcarroll you've got this one. I was trying to use the template outside the element, using it inside the iteration did the trick, nice catch. Maybe add it to the docs? either way this issue will work as a heads up for anyone looking for a solution. My exact use case is via <ng-template let-option #selectTemplate>
<ng-template #popupTemplate>
<div class="header">{{ option.field }}</div>
<div class="content">
{{ option.otherField }}
</div>
</ng-template>
<div suiPopup [popupTemplate]="popupTemplate" popupBasic="true" popupPlacement="bottom right">
{{ option.field }} ({{ option.id }})
</div>
</ng-template>
<sui-select [(ngModel)]="selected" [options]="options" [optionTemplate]="selectTemplate" labelField="field" [isSearchable]="true" #select>
<sui-select-option *ngFor="let option of select.availableOptions" [value]="option">
</sui-select-option>
</sui-select> |
Glad that's sorted it, and yes good idea, will add a note to the docs |
One idea just crash my mind... what if I wanna reuse templates? this workaround will not fix the underlying issue... What about adding a Will result in a code like this <!-- look for let-var and its usage -->
<ng-template let-var #popupTemplate>
<div class="header">{{ var.field }}</div>
<div class="content">
{{ var.otherField }}
</div>
</ng-template>
<!-- look for [value] attr -->
<div suiPopup [popupTemplate]="popupTemplate" popupBasic="true" [value]="option">
{{ option.field }} ({{ option.id }})
</div> |
This isn't a bad idea actually... Though I've made a tonne of changes to the popup component in the datepicker, so will leave this for now until I've merged those changes, otherwise it's futile! |
Ok then, let's wait for the next release! How can we follow this feature request? pst: this issue is still with label investigating |
@genuinefafa this will be in the next release. You can bind a context by setting <ng-template let-popup #popupTemplate>
{{ popup.context.myVariable }}
</ng-template> |
This is now live in |
I see no example using context in docs. Can we add it there too? |
I've just tried making it to work, with no luck. Here's the code I have: ...
<tr *ngFor="let person of people">
<td>{{ person.id }}</td>
<td>{{ person.name }}</td>
<td>
<div class="ui buttons">
<a class="ui button" [routerLink]="['edit',person.id]">
<i class="edit icon"></i> Edit
</a>
<button class="ui icon button" suiPopup [popupTemplate]="confirmDeleteTemplate" [popupTemplateContext]="person" popupTrigger="outsideClick" #popup="suiPopup">
<i class="delete icon"></i> Delete
</button>
</div>
</td>
</tr>
...
<ng-template let-popup #confirmDeleteTemplate>
<div class="header">Delete person</div>
<div class="content">
<p>You are deleting this person, are you sure?</p>
<div class="ui buttons">
<button class="ui positive button" (click)="deletePerson(popup.context.id)">Yes</button>
<button class="ui negative button" (click)="popup.close()">No</button>
</div>
</div>
</ng-template> I'm getting an error because context is undefined, so it seems that the context is not correctly set. Any idea to why that would be? I'm using version 0.9.6 Thanks in advance. |
are you using latest version of semantic-ui? can you provide an example
plunkr?
…On Fri, Aug 25, 2017 at 5:47 AM, Xavier Hahn ***@***.***> wrote:
I've just tried making it to work, with no luck. Here's the code I have:
...
<tr *ngFor="let person of people">
<td>{{ person.id }}</td>
<td>{{ person.name }}</td>
<td>
<div class="ui buttons">
<a class="ui button" [routerLink]="['edit',person.id]">
<i class="edit icon"></i> Edit
</a>
<button class="ui icon button" suiPopup [popupTemplate]="confirmDeleteTemplate" [popupTemplateContext]="person" popupTrigger="outsideClick" #popup="suiPopup">
<i class="delete icon"></i> Delete
</button>
</div>
</td>
</tr>
...
<ng-template let-popup #confirmDeleteTemplate>
<div class="header">Delete person</div>
<div class="content">
<p>You are deleting this person, are you sure?</p>
<div class="ui buttons">
<button class="ui positive button" (click)="deletePerson(popup.context.id)">Yes</button>
<button class="ui negative button" (click)="popup.close()">No</button>
</div>
</div>
</ng-template>
I'm getting an error because context is undefined, so it seems that the
context is not correctly set. Any idea to why that would be?
Thanks in advance.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#127 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABeGXeHoiEcIZxQRXtNUqlBwtCHbf7ZCks5sboo-gaJpZM4OEDll>
.
|
@genuinefafa Yes, I'm indeed using the latest version of semantic-ui. Here's a plunkr that exhibits the issue. Thanks for your help. |
@Gimly thanks for the plunkr. Hmmm, looks like a bug. Will reopen for now and assess properly when I get a chance. Sorry for the delay! |
@edcarroll any news on this? |
Any news on this? |
@edcarroll - is this still an outstanding bug? I am seeing similar behavior in the current alpha build |
Still not working for me. Halp |
I have checked its still not fixed. I am waiting for it too.. |
Just in case anyone is stumbling across this again. This is how it works:
|
@janpapenbrock thank you man) you saved my day! |
I'm creating a site where a
popup
uses a template that needs access to data from scope (let's thing of it as a popup assigned for every item in a*ngFor
).How can I do that? Couldn't find it in the docs.
The text was updated successfully, but these errors were encountered: