Project

General

Profile

1
/**
2
 * @license
3
 * Copyright Google Inc. All Rights Reserved.
4
 *
5
 * Use of this source code is governed by an MIT-style license that can be
6
 * found in the LICENSE file at https://angular.io/license
7
 */
8
import { ElementRef, Injector, OnDestroy, OnInit, Renderer2 } from '@angular/core';
9
import { ControlValueAccessor } from './control_value_accessor';
10
import { NgControl } from './ng_control';
11
export declare const RADIO_VALUE_ACCESSOR: any;
12
/**
13
 * Internal class used by Angular to uncheck radio buttons with the matching name.
14
 */
15
export declare class RadioControlRegistry {
16
    private _accessors;
17
    add(control: NgControl, accessor: RadioControlValueAccessor): void;
18
    remove(accessor: RadioControlValueAccessor): void;
19
    select(accessor: RadioControlValueAccessor): void;
20
    private _isSameGroup(controlPair, accessor);
21
}
22
/**
23
 * @whatItDoes  Writes radio control values and listens to radio control changes.
24
 *
25
 * Used by {@link NgModel}, {@link FormControlDirective}, and {@link FormControlName}
26
 * to keep the view synced with the {@link FormControl} model.
27
 *
28
 * @howToUse
29
 *
30
 * If you have imported the {@link FormsModule} or the {@link ReactiveFormsModule}, this
31
 * value accessor will be active on any radio control that has a form directive. You do
32
 * **not** need to add a special selector to activate it.
33
 *
34
 * ### How to use radio buttons with form directives
35
 *
36
 * To use radio buttons in a template-driven form, you'll want to ensure that radio buttons
37
 * in the same group have the same `name` attribute.  Radio buttons with different `name`
38
 * attributes do not affect each other.
39
 *
40
 * {@example forms/ts/radioButtons/radio_button_example.ts region='TemplateDriven'}
41
 *
42
 * When using radio buttons in a reactive form, radio buttons in the same group should have the
43
 * same `formControlName`. You can also add a `name` attribute, but it's optional.
44
 *
45
 * {@example forms/ts/reactiveRadioButtons/reactive_radio_button_example.ts region='Reactive'}
46
 *
47
 *  * **npm package**: `@angular/forms`
48
 *
49
 *  @stable
50
 */
51
export declare class RadioControlValueAccessor implements ControlValueAccessor, OnDestroy, OnInit {
52
    private _renderer;
53
    private _elementRef;
54
    private _registry;
55
    private _injector;
56
    onChange: () => void;
57
    onTouched: () => void;
58
    name: string;
59
    formControlName: string;
60
    value: any;
61
    constructor(_renderer: Renderer2, _elementRef: ElementRef, _registry: RadioControlRegistry, _injector: Injector);
62
    ngOnInit(): void;
63
    ngOnDestroy(): void;
64
    writeValue(value: any): void;
65
    registerOnChange(fn: (_: any) => {}): void;
66
    fireUncheck(value: any): void;
67
    registerOnTouched(fn: () => {}): void;
68
    setDisabledState(isDisabled: boolean): void;
69
    private _checkName();
70
    private _throwNameError();
71
}
(17-17/24)