7

I have simple Angular-Dart component, trying connect property to ngModel in radio input, app compiling correctly, but browser console gives me error:

No provider found for RadioControlRegistry: RadioControlValueAccessor -> RadioControlRegistry.

the code:

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

whats wrong?

Kevin Moore
  • 5,921
  • 2
  • 29
  • 43
PavelS57
  • 71
  • 3

2 Answers2

0

Try adding RadioControlRegistry under providers array

 providers: [ClassProvider(RadioControlRegistry)]
Sajeetharan
  • 216,225
  • 63
  • 350
  • 396
  • No dice, get `Arguments of a constant creation must be constant expressions`, and there's a syntax error in the linked github response (no `,` after `directives`). I think it might actually be `providers: [FORM_PROVIDERS]` – Ryan Haining Aug 04 '19 at 17:43
0

You need providers: [FORM_PROVIDERS] in your component

@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 {
  // ...
}
Ryan Haining
  • 35,360
  • 15
  • 114
  • 174