dart - 角 Dart : Property binding ngIf not used by any directive on an embedded template error while using *ngIf

标签 dart angular-dart dart-html angular-ng-if

我正在使用 AngularDart,我需要根据 bool 值 registerDisplay 显示和隐藏组件。尝试使用 *ngIf ,但抛出错误。以下是 html。

app_component.html:

<div *ngIf="!registerDisplay">
    <register-component></register-component>
</div>

enter image description here

可能是什么原因。我遇到了 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/

相关文章:

firebase - Flutter cloud_firestore 系统日期对象的设置/警告

jquery - Google Dart 表单工作示例

dart - 如何在我的Web应用程序中设置Dart的HttpRequest发出的请求的MIME类型?

dart - 更改DART中svg行的长度

flutter - 如何在 flutter 测试中模拟 onDoubleTap

dart - 处理 Flutter 中的特殊字符

webstorm - 无法与适用于 Web 的 Angular 和适用于移动项目的 Flutter 一起运行 Dart 2 - 计划共享代码

angular - 用于将数据传递到Angular指令的语法

css - 如何在AngularDart元素中将div图像与中心对齐?