@@ -16,7 +16,6 @@ abstract class NgControl implements NgAttachAware, NgDetachAware {
16
16
bool _valid;
17
17
bool _submit_valid;
18
18
19
- final Scope _scope;
20
19
final NgControl _parentControl;
21
20
final NgAnimate _animate;
22
21
dom.Element _element;
@@ -25,14 +24,12 @@ abstract class NgControl implements NgAttachAware, NgDetachAware {
25
24
final List <NgControl > _controls = new List <NgControl >();
26
25
final Map <String , List <NgControl >> _controlByName = new Map <String , List <NgControl >>();
27
26
28
- NgControl (Scope this ._scope, dom.Element this ._element, Injector injector,
27
+ NgControl (dom.Element this ._element, Injector injector,
29
28
NgAnimate this ._animate)
30
29
: _parentControl = injector.parent.get (NgControl )
31
30
{
32
31
pristine = true ;
33
32
untouched = true ;
34
-
35
- _scope.on ('submitNgControl' ).listen ((e) => _onSubmit (e.data));
36
33
}
37
34
38
35
@override
@@ -49,13 +46,15 @@ abstract class NgControl implements NgAttachAware, NgDetachAware {
49
46
}
50
47
51
48
reset () {
52
- _scope.broadcast ('resetNgModel' );
53
49
untouched = true ;
50
+ _controls.forEach ((control) {
51
+ control.reset ();
52
+ });
54
53
}
55
54
56
55
bool hasError (String key) => errors.containsKey (key);
57
56
58
- _onSubmit (bool valid) {
57
+ onSubmit (bool valid) {
59
58
if (valid) {
60
59
_submit_valid = true ;
61
60
_animate.addClass (element, NG_SUBMIT_VALID_CLASS );
@@ -65,6 +64,9 @@ abstract class NgControl implements NgAttachAware, NgDetachAware {
65
64
_animate.addClass (element, NG_SUBMIT_INVALID_CLASS );
66
65
_animate.removeClass (element, NG_SUBMIT_VALID_CLASS );
67
66
}
67
+ _controls.forEach ((control) {
68
+ control.onSubmit (valid);
69
+ });
68
70
}
69
71
70
72
get submitted => _submit_valid != null ;
@@ -198,14 +200,13 @@ abstract class NgControl implements NgAttachAware, NgDetachAware {
198
200
}
199
201
200
202
class NgNullControl implements NgControl {
201
- var _name, _dirty, _valid, _invalid, _submit_valid, _pristine, _element;
202
- var _touched, _untouched;
203
- var _controls, _scope, _parentControl, _controlName, _animate;
203
+ var _name, _dirty, _valid, _submit_valid, _pristine, _element, _touched;
204
+ var _controls, _parentControl, _controlName, _animate;
204
205
var errors, _controlByName;
205
206
dom.Element element;
206
207
207
208
NgNullControl () {}
208
- _onSubmit (bool valid) {}
209
+ onSubmit (bool valid) {}
209
210
210
211
addControl (control) {}
211
212
removeControl (control) {}
0 commit comments