-
Notifications
You must be signed in to change notification settings - Fork 89
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 I use ngClass on the ng-template? #89
Comments
You can't put element attributes on an
If all you want to do is write a css rule for the first context menu item, you can do that without a class.
|
Yes, I expect your solution would generally work in pure HTML. Alas, my context menu is defined in the middle of SVG markup, which generally works, but chokes on having a <svg:g *ngFor="let thing of things">[contextMenu]="thingMenu" [contextMenuSubject]="thing"></svg:g>
<context-menu #thingMenu>
<ng-template contextMenuItem (execute)="toggleThing($event.item)">
<div [ngClass]="{'my-special-class': $event.item.isThingSpecial}">Do something</div>
</ng-template>
</context-menu> My use case is to use |
The |
Yeah, that is precisely the problem. My entire component template is SVG, no HTML at all, until I add the
|
Here's what I would do:
|
In you css file => In the HTML file =>
OR In the HTML file =>
In the component file .ts
In the Interface file declare custom type property
|
Id like to add a class to a menu item conditionally.
<ng-template contextMenuItem (execute)="doSomething($event.item)" [ngClass]="{'first': true}">
but get a console error: TypeError: Cannot read property 'add' of undefined
Even better, I'd like to reference the item's properties, like
[ngClass]="{'first': $event.item.isSnapToGrid}"
but I get: ReferenceError: $event is not defined
The text was updated successfully, but these errors were encountered: