AngularDart:如何一次性将 providers/directives 添加到子组件
AngularDart: how to add providers/directives to sub-components in one time
当我尝试将字符串绑定到 ngModel 时出现以下错误:
Error: Template parse errors:
line 2, column 21 of ChatFormComponent: ParseErrorLevel.FATAL: Can't bind to 'ngModel' since it isn't a known native property or known directive. Please fix typo or add to directives list.
[(ngModel)]="message"
这个错误是因为组件中缺少formsDirectives:
https://webdev.dartlang.org/angular/tutorial/toh-pt1#declare-non-core-directives
我添加后有效。但是,我厌倦了为每个组件一个一个地添加指令。我有两个问题:
- angularDart 中有类似 AppModule 的东西吗?这样所有在 AppModule 中注册的 provider/directives 都适用于每个子组件。如果存在,是否建议使用?
- 有没有其他快速的方法可以将providers/directives一次添加到所有子组件?
谢谢
您需要为每个组件添加提供程序。没办法了。
当我尝试将字符串绑定到 ngModel 时出现以下错误:
Error: Template parse errors: line 2, column 21 of ChatFormComponent: ParseErrorLevel.FATAL: Can't bind to 'ngModel' since it isn't a known native property or known directive. Please fix typo or add to directives list. [(ngModel)]="message"
这个错误是因为组件中缺少formsDirectives: https://webdev.dartlang.org/angular/tutorial/toh-pt1#declare-non-core-directives
我添加后有效。但是,我厌倦了为每个组件一个一个地添加指令。我有两个问题:
- angularDart 中有类似 AppModule 的东西吗?这样所有在 AppModule 中注册的 provider/directives 都适用于每个子组件。如果存在,是否建议使用?
- 有没有其他快速的方法可以将providers/directives一次添加到所有子组件?
谢谢
您需要为每个组件添加提供程序。没办法了。