refactor(forms): upgrade to @angular/forms

This commit is contained in:
Adam Bradley
2016-06-30 21:54:48 -05:00
parent 9b2f4a682e
commit 4d56219a4c
42 changed files with 219 additions and 249 deletions

View File

@ -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();