@@ -64,34 +64,10 @@ import '../../utils/disposer/disposer.dart';
6464class MaterialRadioGroupComponent implements ControlValueAccessor , OnDestroy {
6565 final _disposer = new Disposer .oneShot ();
6666 final ManagedZone _managedZone;
67+ final NgControl cd;
6768 List <MaterialRadioComponent > _children;
6869
69- MaterialRadioGroupComponent (
70- this ._managedZone,
71- @ContentChildren (MaterialRadioComponent ) QueryList components,
72- @Self () @Optional () NgControl cd) {
73- _disposer.addStreamSubscription (components.changes.listen ((_) {
74- _children = new List .from (components);
75- for (var child in _children) {
76- _disposer
77- ..addStreamSubscription (child.focusmove.listen (_moveFocus))
78- ..addStreamSubscription (child.selectionmove.listen (_moveSelection));
79- }
80- if (_preselectedValue != null ) {
81- // Since this is updating children that were already dirty-checked,
82- // need to delay this change until next angular cycle.
83- _managedZone.onTurnDone.first.then ((_) {
84- // Initialize preselect now, this will trigger tabIndex reset.
85- selected = _preselectedValue;
86- // The preselected value should be used only once.
87- _preselectedValue = null ;
88- });
89- } else {
90- // Initialize tabIndex.
91- _resetTabIndex ();
92- }
93- }));
94-
70+ MaterialRadioGroupComponent (this ._managedZone, @Self () @Optional () this .cd) {
9571 _disposer.addStreamSubscription (componentSelection.selectionChanges
9672 .listen ((List <SelectionChangeRecord <MaterialRadioComponent >> changes) {
9773 // Need to uncheck if selection change was made via user action.
@@ -121,9 +97,32 @@ class MaterialRadioGroupComponent implements ControlValueAccessor, OnDestroy {
12197
12298 // When NgControl is present on the host element, the component
12399 // participates in the Forms API.
124- if (cd != null ) {
125- cd.valueAccessor = this ;
126- }
100+ cd? .valueAccessor = this ;
101+ }
102+
103+ @ContentChildren (MaterialRadioComponent )
104+ set list (QueryList components) {
105+ _disposer.addStreamSubscription (components.changes.listen ((_) {
106+ _children = new List .from (components);
107+ for (var child in _children) {
108+ _disposer
109+ ..addStreamSubscription (child.focusmove.listen (_moveFocus))
110+ ..addStreamSubscription (child.selectionmove.listen (_moveSelection));
111+ }
112+ if (_preselectedValue != null ) {
113+ // Since this is updating children that were already dirty-checked,
114+ // need to delay this change until next angular cycle.
115+ _managedZone.onTurnDone.first.then ((_) {
116+ // Initialize preselect now, this will trigger tabIndex reset.
117+ selected = _preselectedValue;
118+ // The preselected value should be used only once.
119+ _preselectedValue = null ;
120+ });
121+ } else {
122+ // Initialize tabIndex.
123+ _resetTabIndex ();
124+ }
125+ }));
127126 }
128127
129128 @override
0 commit comments