dart - AngularDart:在使用 *ngIf 时,任何指令都没有使用嵌入模板错误的属性绑定 ngIf
问题描述
我正在使用 AngularDart,我需要根据布尔值registerDisplay显示和隐藏组件。尝试使用*ngIf,但抛出错误。下面是html。
app_component.html:
<div *ngIf="!registerDisplay">
<register-component></register-component>
</div>
可能是什么原因。我遇到了 Angular typescript 中错误的解决方案。但这不适用于飞镖。请建议。
解决方案
您需要注册要在模板中使用的指令
@Component(
selector: 'my-component',
directives: const [
MaterialButtonComponent,
MaterialIconComponent,
MaterialTooltipDirective,
...
NgIf,
...
],
您可以通过添加来注册 Angular 本身提供的公共集,而不是单独注册每个指令
coreDirectives,
到directives
列表中。
另请参阅https://github.com/dart-lang/angular/blob/master/angular/lib/src/common/common_directives.dart
推荐阅读
- slurm - SLURM 环境变量为空
- javascript - HTML 和 jQuery 返回按钮位置不停留
- javascript - React 模态窗口不显示 Hooks
- tensorflow - Keras.module需要Tf版本=>2.2,但是DLL的Tf加载失败
- php - PHPUnit: How to test a class method that uses another static classes method
- xamarin.forms - 如何显示内容查看标签页的标签
- javascript - 当您将鼠标悬停在某物上时,这个弹出的东西是什么?
- java - 在 Java 中验证对 GitHub API 的 http 调用
- python - python合并和不匹配的记录也需要存在
- c# - 两种不同的类型,一种 C# 中的方法实现