We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
ref
有个指令,我想它有时候被添加上,有时候去除,可以传进去一个布尔值来实现吗?
不可以。没办法直接使用条件判断是否添加指令,不过可以分成两部分,一个添加了指令的区域,一个未添加的,再通过判断显示哪个。
未避免代码冗余将公用的部分抽取出来:
<ng-template #shared> <div>这是一个共享的内容</div> </ng-template>
需要添加指令
<div *ngIf="show" yourDirective> <ng-container *ngTemplateOutlet="shared"></ng-container> </div>
不需要添加指令
<div *ngIf="!show"> <ng-container *ngTemplateOutlet="shared"></ng-container> </div>
The text was updated successfully, but these errors were encountered:
No branches or pull requests
如何根据条件决定是否添加指令
有个指令,我想它有时候被添加上,有时候去除,可以传进去一个布尔值来实现吗?
不可以。没办法直接使用条件判断是否添加指令,不过可以分成两部分,一个添加了指令的区域,一个未添加的,再通过判断显示哪个。
未避免代码冗余将公用的部分抽取出来:
需要添加指令
不需要添加指令
The text was updated successfully, but these errors were encountered: