mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-22 05:21:52 +08:00
refactor(forms): upgrade to @angular/forms
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import { Component, ElementRef, EventEmitter, forwardRef, Input, Optional, Output, Provider, Renderer, ViewEncapsulation } from '@angular/core';
|
||||
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/common';
|
||||
import { AfterContentInit, Component, ElementRef, EventEmitter, forwardRef, Input, OnDestroy, Optional, Output, Provider, Renderer, ViewEncapsulation } from '@angular/core';
|
||||
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
|
||||
|
||||
import { Form } from '../../util/form';
|
||||
import { isTrueProperty } from '../../util/util';
|
||||
@ -70,7 +70,7 @@ const TOGGLE_VALUE_ACCESSOR = new Provider(
|
||||
providers: [TOGGLE_VALUE_ACCESSOR],
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
})
|
||||
export class Toggle implements ControlValueAccessor {
|
||||
export class Toggle implements AfterContentInit, ControlValueAccessor, OnDestroy {
|
||||
private _checked: boolean = false;
|
||||
private _init: boolean;
|
||||
private _disabled: boolean = false;
|
||||
@ -225,7 +225,7 @@ export class Toggle implements ControlValueAccessor {
|
||||
* @private
|
||||
*/
|
||||
onChange(isChecked: boolean) {
|
||||
// used when this input does not have an ngModel or ngControl
|
||||
// used when this input does not have an ngModel or formControlName
|
||||
console.debug('toggle, onChange (no ngModel)', isChecked);
|
||||
this._setChecked(isChecked);
|
||||
this.onTouched();
|
||||
|
Reference in New Issue
Block a user