我正在包装角度材质菜单组件。我正在扩展 MatMenuTrigger、MatMenuItem,将它们作为单独的指令并在父组件中使用它。在子组件(菜单组件)中,我仅使用 mat-menu 来获取引用,在父组件(菜单演示组件)中,将菜单(位于子组件中)附加到我们想要的任何控件。我不应该在子组件内使用按钮标签,所以我使用 ng-content 从父组件获取内容。我只想公开一些属性来获取该引用。我的问题是如何包装这个参考菜单stackblitzlink。请帮我解决这个问题,提前致谢。
我想根据为应用程序组件中的变量提供的值添加 mat-accordion "displayMode" 的属性。
我正在使用 ng-if 来制作它。但我收到错误。
<mat-accordion class="accord-align" *ngIf="displayType" then displayMode="{{displayType}}" ><br/>
<<Some tags and text here>><br/>
</mat-accordion><br/>
Run Code Online (Sandbox Code Playgroud)
如果我提供这样的 *ngIf="displayType" 然后 displayMode="{{displayType}}",那么它的显示错误说
compiler.es5.js:1694 Uncaught Error: Template parse errors:<><br/>
Parser Error: Bindings cannot contain assignments at column 30 in [displayType then displayMode={{displayType}}] in ng:///AppModule/AccordionComponent.html@1:38 ("<div id="divi-align"> <br/>
<mat-accordion class="accord-align" [ERROR ->]*ngIf="displayType then displayMode={{displayType}}" >
<mat-expansion-panel class="panel1-align""): ng:///AppModule/AccordionComponent.html@1:38<br/>
Can't bind to '*ngIf' since it isn't a known property of 'mat-accordion'.<br/>
1. If 'mat-accordion' is an Angular component and it has '*ngIf' …Run Code Online (Sandbox Code Playgroud)