Skip to content

Instantly share code, notes, and snippets.

@alexzuza
Created October 14, 2017 17:54
Show Gist options
  • Save alexzuza/2802eae86143f0164ec4bf995ad49ee2 to your computer and use it in GitHub Desktop.
Save alexzuza/2802eae86143f0164ec4bf995ad49ee2 to your computer and use it in GitHub Desktop.
@Directive({selector: '[ngModelGroup]', providers: [modelGroupProvider], exportAs: 'ngModelGroup'})
export class NgModelGroup extends AbstractFormGroupDirective implements OnInit, OnDestroy {
@Input('ngModelGroup') name: string;
constructor(
@Host() @SkipSelf() parent: ControlContainer,
@Optional() @Self() @Inject(NG_VALIDATORS) validators: any[],
@Optional() @Self() @Inject(NG_ASYNC_VALIDATORS) asyncValidators: any[]) {
super();
this._parent = parent;
this._validators = validators;
this._asyncValidators = asyncValidators;
}
/** @internal */
_checkParentType(): void {
if (!(this._parent instanceof NgModelGroup) && !(this._parent instanceof NgForm)) {
TemplateDrivenErrors.modelGroupParentException();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment