|
1 | 1 | import { Inject, Injectable, Optional } from '@angular/core'; |
2 | | -import { AbstractControl, FormGroup, FormArray } from '@angular/forms'; |
3 | | -import { coerceArray, filterControlKeys, filterNil, isBrowser, mergeDeep } from './utils'; |
| 2 | +import { AbstractControl, FormArray, FormGroup } from '@angular/forms'; |
4 | 3 | import { EMPTY, merge, Observable, Subject, Subscription, timer } from 'rxjs'; |
5 | | -import { debounce, distinctUntilChanged, filter, map, mapTo, tap } from 'rxjs/operators'; |
| 4 | +import { debounce, distinctUntilChanged, filter, map, mapTo } from 'rxjs/operators'; |
| 5 | +import { deleteControl, findControl, handleFormArray, toStore } from './builders'; |
| 6 | +import { Config, NgFormsManagerConfig, NG_FORMS_MANAGER_CONFIG } from './config'; |
6 | 7 | import { FormsStore } from './forms-manager.store'; |
7 | | -import { Control, ControlFactory, FormKeys, HashMap, UpsertConfig } from './types'; |
8 | | -import { Config, NG_FORMS_MANAGER_CONFIG, NgFormsManagerConfig } from './config'; |
9 | 8 | import { isEqual } from './isEqual'; |
10 | | -import { deleteControl, findControl, handleFormArray, toStore } from './builders'; |
| 9 | +import { Control, ControlFactory, FormKeys, HashMap, UpsertConfig } from './types'; |
| 10 | +import { coerceArray, filterControlKeys, filterNil, isBrowser, mergeDeep } from './utils'; |
11 | 11 |
|
12 | 12 | const NO_DEBOUNCE = Symbol('NO_DEBOUNCE'); |
13 | 13 |
|
@@ -266,6 +266,28 @@ export class NgFormsManager<FormsState = any> { |
266 | 266 | } |
267 | 267 | } |
268 | 268 |
|
| 269 | + /** |
| 270 | + * |
| 271 | + * @example |
| 272 | + * |
| 273 | + * A proxy to the original `reset` method |
| 274 | + * |
| 275 | + * manager.reset('login', { email: '' }); |
| 276 | + * |
| 277 | + */ |
| 278 | + reset<T extends keyof FormsState>( |
| 279 | + name: T, |
| 280 | + value?: Partial<FormsState[T]>, |
| 281 | + options?: { |
| 282 | + onlySelf?: boolean; |
| 283 | + emitEvent?: boolean; |
| 284 | + } |
| 285 | + ) { |
| 286 | + if (this.instances$$.has(name)) { |
| 287 | + this.instances$$.get(name).reset(value, options); |
| 288 | + } |
| 289 | + } |
| 290 | + |
269 | 291 | /** |
270 | 292 | * |
271 | 293 | * Sets the initial value for a control |
|
0 commit comments