-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Can't use scope variables inside a popover/tooltip TemplateReference #3490
Comments
It is not a problem of ng-zorro, angular does not support this: <!-- Can not be rendered too -->
<div *ngFor="let item of items">
<ng-container [ngTemplateOutlet]="popoverVarsContent"></ng-container>
</div>
<ng-template #popoverVarsContent>
<p>Item: {{item | json}}</p>
</ng-template> You should create a new component and use |
@javcode You can move <div *ngFor="let item of items">
<ng-container [ngTemplateOutlet]="popoverVarsContent"></ng-container>
<ng-template #popoverVarsContent>
<p>Item: {{item | json}}</p>
</ng-template>
</div> |
I've ended up creating a new Component taking the 'item' as an input as I wanted to be able to re-use this code as it's used in several places. export class ImportPopoverComponent implements OnInit {
@Input()
item:{}
} Now the new component html looks like: <a href="javascript:void(0)" nz-popover [nzContent]="popover">Add Item</a>
<ng-template #popover>
<div>{{item}}</div>
</ng-template> and I call it from the parent using: <app-import-popover [item]="item"></app-import-popover> Thanks wenqi73 for the work-around |
Works like a charm. |
Reproduction link
https://stackblitz.com/edit/ng-zorro-antd-start-scmfqv
Steps to reproduce
Create a tooltip inside an *ngFor and try to access the declared variable from inside the ng-template
What is expected?
The scope variable should be accessible and rendered inside the ng-template used by the popover/tooltip
What is actually happening?
The variable is undefined
The text was updated successfully, but these errors were encountered: