我正在使用 AngularDart,我需要根据 bool 值 registerDisplay 显示和隐藏组件。尝试使用 *ngIf ,但抛出错误。以下是 html。
app_component.html:
<div *ngIf="!registerDisplay">
<register-component></register-component>
</div>
可能是什么原因。我遇到了 Angular typescript 错误的解决方案。但这不适用于 Dart 。请建议。
最佳答案
您需要在模板中注册要使用的指令
@Component(
selector: 'my-component',
directives: const [
MaterialButtonComponent,
MaterialIconComponent,
MaterialTooltipDirective,
...
NgIf,
...
],
无需单独注册每个指令,您可以注册 Angular 本身通过添加
提供的通用集coreDirectives,
到指令
列表。
另见 https://github.com/dart-lang/angular/blob/master/angular/lib/src/common/common_directives.dart
关于dart - 角 Dart : Property binding ngIf not used by any directive on an embedded template error while using *ngIf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50758252/