我有简单的Angular-Dart组件,尝试将属性连接到无线输入中的ngModel,应用程序正确编译,但浏览器控制台给我错误:
No provider found for RadioControlRegistry: RadioControlValueAccessor -> RadioControlRegistry.代码:
import 'package:angular/angular.dart';
import 'package:angular_forms/angular_forms.dart';
@Component(
selector: 'order-question-test',
template: '''
<input type="radio" name="food" [(ngModel)]="foodChicken">
<input type="radio" name="food" [(ngModel)]="foodFish">
''',
directives: [
coreDirectives,
formDirectives,
]
)
class OrderQuestion {
RadioButtonState foodChicken = RadioButtonState(true, "chicken");
RadioButtonState foodFish = RadioButtonState(false, "fish");
OrderQuestion ();
}pubspec.yaml
environment:
sdk: '>=2.2.0 <3.0.0'
dependencies:
angular: ^5.2.0
angular_components: ^0.13.0
json_annotation: ^2.0.0
dev_dependencies:
angular_test: ^2.2.0
build_runner: ^1.5.0
build_test: ^0.10.3
build_web_compilers: ^1.0.0
json_serializable: ^2.0.0
pedantic: ^1.0.0
test: ^1.5.1怎么了?
发布于 2019-08-04 14:19:19
尝试在providers数组下添加RadioControlRegistry
providers: [ClassProvider(RadioControlRegistry)]发布于 2019-08-06 03:42:10
您的组件中需要providers: [FORM_PROVIDERS]
@Component(
selector: 'order-question-test',
template: '''
<input type="radio" name="food" [(ngModel)]="foodChicken">
<input type="radio" name="food" [(ngModel)]="foodFish">
''',
directives: [
coreDirectives,
formDirectives,
],
providers: [FORM_PROVIDERS] // added
)
class OrderQuestion {
// ...
}https://stackoverflow.com/questions/56908118
复制相似问题