diff --git a/src/components/checkbox/checkbox.ts b/src/components/checkbox/checkbox.ts index 91077652799..102a023d78b 100644 --- a/src/components/checkbox/checkbox.ts +++ b/src/components/checkbox/checkbox.ts @@ -1,4 +1,4 @@ -import { AfterViewInit, ChangeDetectorRef, Component, ElementRef, HostListener, Input, OnDestroy, Optional, Renderer, ViewEncapsulation } from '@angular/core'; +import { ChangeDetectorRef, Component, ElementRef, HostListener, Input, OnDestroy, Optional, Renderer, ViewEncapsulation } from '@angular/core'; import { NG_VALUE_ACCESSOR } from '@angular/forms'; import { Config } from '../../config/config'; @@ -66,7 +66,7 @@ import { Item } from '../item/item'; providers: [ { provide: NG_VALUE_ACCESSOR, useExisting: Checkbox, multi: true } ], encapsulation: ViewEncapsulation.None, }) -export class Checkbox extends BaseInput implements IonicTapInput, AfterViewInit, OnDestroy { +export class Checkbox extends BaseInput implements IonicTapInput, OnDestroy { /** * @input {boolean} If true, the element is selected. diff --git a/src/components/datetime/datetime.ts b/src/components/datetime/datetime.ts index fa492838fec..d9e385c1cfb 100644 --- a/src/components/datetime/datetime.ts +++ b/src/components/datetime/datetime.ts @@ -1,4 +1,4 @@ -import { AfterViewInit, Component, ElementRef, EventEmitter, HostListener, Input, OnDestroy, Optional, Output, Renderer, ViewEncapsulation } from '@angular/core'; +import { AfterContentInit, Component, ElementRef, EventEmitter, HostListener, Input, OnDestroy, Optional, Output, Renderer, ViewEncapsulation } from '@angular/core'; import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; import { Config } from '../../config/config'; @@ -267,7 +267,7 @@ import { dateValueRange, renderDateTime, renderTextFormat, convertDataToISO, con providers: [ { provide: NG_VALUE_ACCESSOR, useExisting: DateTime, multi: true } ], encapsulation: ViewEncapsulation.None, }) -export class DateTime extends BaseInput implements AfterViewInit, ControlValueAccessor, OnDestroy { +export class DateTime extends BaseInput implements AfterContentInit, ControlValueAccessor, OnDestroy { _text: string = ''; _min: DateTimeData; @@ -425,7 +425,7 @@ export class DateTime extends BaseInput implements AfterViewInit, /** * @hidden */ - ngAfterViewInit() { + ngAfterContentInit() { // first see if locale names were provided in the inputs // then check to see if they're in the config // if neither were provided then it will use default English names diff --git a/src/components/datetime/test/datetime.spec.ts b/src/components/datetime/test/datetime.spec.ts index 6e2f52d0631..847d8c32f73 100644 --- a/src/components/datetime/test/datetime.spec.ts +++ b/src/components/datetime/test/datetime.spec.ts @@ -144,7 +144,7 @@ describe('DateTime', () => { describe('writeValue', () => { it('should updateText with default MMM D, YYYY when no displayFormat or pickerFormat', zoned(() => { - datetime.ngAfterViewInit(); + datetime.ngAfterContentInit(); datetime.writeValue('1994-12-15T13:47:20.789Z'); expect(datetime._text).toEqual('Dec 15, 1994'); @@ -152,7 +152,7 @@ describe('DateTime', () => { it('should updateText with pickerFormat when no displayFormat', zoned(() => { datetime.pickerFormat = 'YYYY'; - datetime.ngAfterViewInit(); + datetime.ngAfterContentInit(); datetime.writeValue('1994-12-15T13:47:20.789Z'); expect(datetime._text).toEqual('1994'); @@ -160,7 +160,7 @@ describe('DateTime', () => { it('should updateText with displayFormat when no pickerFormat', zoned(() => { datetime.displayFormat = 'YYYY'; - datetime.ngAfterViewInit(); + datetime.ngAfterContentInit(); datetime.writeValue('1994-12-15T13:47:20.789Z'); expect(datetime._text).toEqual('1994'); @@ -172,7 +172,7 @@ describe('DateTime', () => { it('should generate with default MMM D, YYYY when no displayFormat or pickerFormat', zoned(() => { datetime.monthShortNames = customLocale.monthShortNames; - datetime.ngAfterViewInit(); + datetime.ngAfterContentInit(); datetime.setValue('1994-12-15T13:47:20.789Z'); datetime.generate(); @@ -186,7 +186,7 @@ describe('DateTime', () => { it('should generate with only displayFormat', zoned(() => { datetime.monthShortNames = customLocale.monthShortNames; - datetime.ngAfterViewInit(); + datetime.ngAfterContentInit(); datetime.displayFormat = 'YYYY'; datetime.setValue('1994-12-15T13:47:20.789Z'); @@ -199,7 +199,7 @@ describe('DateTime', () => { it('should generate with only pickerFormat', zoned(() => { datetime.monthShortNames = customLocale.monthShortNames; - datetime.ngAfterViewInit(); + datetime.ngAfterContentInit(); datetime.pickerFormat = 'YYYY'; datetime.setValue('1994-12-15T13:47:20.789Z'); @@ -212,7 +212,7 @@ describe('DateTime', () => { it('should generate with custom locale short month names from input property', zoned(() => { datetime.monthShortNames = customLocale.monthShortNames; - datetime.ngAfterViewInit(); + datetime.ngAfterContentInit(); datetime.pickerFormat = 'MMM YYYY'; datetime.setValue('1994-12-15T13:47:20.789Z'); @@ -227,7 +227,7 @@ describe('DateTime', () => { it('should generate with custom locale full month names from input property', zoned(() => { datetime.monthNames = customLocale.monthNames; - datetime.ngAfterViewInit(); + datetime.ngAfterContentInit(); datetime.pickerFormat = 'MMMM YYYY'; datetime.setValue('1994-12-15T13:47:20.789Z'); diff --git a/src/components/range/range.ts b/src/components/range/range.ts index 64f0ac86b94..ea4dd6b8db6 100644 --- a/src/components/range/range.ts +++ b/src/components/range/range.ts @@ -1,4 +1,4 @@ -import { AfterViewInit, ChangeDetectorRef, Component, ElementRef, Input, OnDestroy, Optional, Renderer, ViewChild, ViewEncapsulation } from '@angular/core'; +import { AfterContentInit, ChangeDetectorRef, Component, ElementRef, Input, OnDestroy, Optional, Renderer, ViewChild, ViewEncapsulation } from '@angular/core'; import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; import { clamp, isTrueProperty } from '../../util/util'; @@ -104,7 +104,7 @@ import { UIEventManager } from '../../gestures/ui-event-manager'; providers: [ { provide: NG_VALUE_ACCESSOR, useExisting: Range, multi: true } ], encapsulation: ViewEncapsulation.None, }) -export class Range extends BaseInput implements AfterViewInit, ControlValueAccessor, OnDestroy { +export class Range extends BaseInput implements AfterContentInit, ControlValueAccessor, OnDestroy { _dual: boolean; _pin: boolean; @@ -266,7 +266,7 @@ export class Range extends BaseInput implements AfterViewInit, ControlValue /** * @hidden */ - ngAfterViewInit() { + ngAfterContentInit() { this._initialize(); // add touchstart/mousedown listeners diff --git a/src/components/searchbar/searchbar.ts b/src/components/searchbar/searchbar.ts index 6b43dd60a6b..fa0a70468b9 100644 --- a/src/components/searchbar/searchbar.ts +++ b/src/components/searchbar/searchbar.ts @@ -172,15 +172,6 @@ export class Searchbar extends BaseInput { @ViewChild('cancelButton', {read: ElementRef}) _cancelButton: ElementRef; - /** - * @hidden - * After View Checked position the elements - */ - ngAfterViewInit() { - this._initialize(); - this.positionElements(); - } - /** * @hidden * On Initialization check for attributes @@ -196,11 +187,9 @@ export class Searchbar extends BaseInput { * @hidden */ _inputUpdated() { - if (this._searchbarInput) { - var ele = this._searchbarInput.nativeElement; - if (ele) { - ele.value = this.value; - } + const ele = this._searchbarInput.nativeElement; + if (ele) { + ele.value = this.value; } this.positionElements(); } @@ -229,9 +218,6 @@ export class Searchbar extends BaseInput { } positionPlaceholder() { - if (!this._searchbarInput || !this._searchbarIcon) { - return; - } const inputEle = this._searchbarInput.nativeElement; const iconEle = this._searchbarIcon.nativeElement; @@ -265,9 +251,6 @@ export class Searchbar extends BaseInput { * Show the iOS Cancel button on focus, hide it offscreen otherwise */ positionCancelButton() { - if (!this._cancelButton || !this._cancelButton.nativeElement) { - return; - } const showShowCancel = this._isFocus; if (showShowCancel !== this._isCancelVisible) { var cancelStyleEle = this._cancelButton.nativeElement; diff --git a/src/components/searchbar/test/basic/pages/root-page/root-page.html b/src/components/searchbar/test/basic/pages/root-page/root-page.html index 19d9f2a6adb..44d3500c936 100644 --- a/src/components/searchbar/test/basic/pages/root-page/root-page.html +++ b/src/components/searchbar/test/basic/pages/root-page/root-page.html @@ -44,4 +44,10 @@
Search - Animated and No Cancel

+ + +
+ +
+ \ No newline at end of file diff --git a/src/components/searchbar/test/basic/pages/root-page/root-page.ts b/src/components/searchbar/test/basic/pages/root-page/root-page.ts index a251e2e4e1d..093582aa0b5 100644 --- a/src/components/searchbar/test/basic/pages/root-page/root-page.ts +++ b/src/components/searchbar/test/basic/pages/root-page/root-page.ts @@ -13,6 +13,7 @@ export class RootPage { isAutocorrect: string = 'on'; isAutocomplete: string = 'on'; isSpellcheck: boolean = true; + activeTab = ''; constructor(private changeDetectorRef: ChangeDetectorRef) { diff --git a/src/components/segment/segment.ts b/src/components/segment/segment.ts index dcc7db713f3..0af6e4805dd 100644 --- a/src/components/segment/segment.ts +++ b/src/components/segment/segment.ts @@ -1,8 +1,9 @@ -import { ContentChildren, Directive, ElementRef, Optional, QueryList, Renderer } from '@angular/core'; +import { AfterContentInit, ContentChildren, Directive, ElementRef, Optional, QueryList, Renderer } from '@angular/core'; import { NgControl } from '@angular/forms'; import { Config } from '../../config/config'; import { BaseInput } from '../../util/base-input'; +import { assert } from '../../util/util'; import { SegmentButton } from './segment-button'; /** @@ -67,7 +68,7 @@ import { SegmentButton } from './segment-button'; '[class.segment-disabled]': '_disabled' } }) -export class Segment extends BaseInput { +export class Segment extends BaseInput implements AfterContentInit { /** * @hidden @@ -86,7 +87,7 @@ export class Segment extends BaseInput { /** * @hidden */ - ngAfterViewInit() { + ngAfterContentInit() { this._initialize(); this._buttons.forEach(button => { button.ionSelect.subscribe((selectedButton: any) => this.value = selectedButton.value); @@ -98,12 +99,14 @@ export class Segment extends BaseInput { * Write a new value to the element. */ _inputUpdated() { - if (this._buttons) { - var buttons = this._buttons.toArray(); - var value = this.value; - for (var button of buttons) { - button.isActive = (button.value === value); - } + if (!this._buttons) { + assert(false, 'buttons are undefined'); + return; + } + const buttons = this._buttons.toArray(); + const value = this.value; + for (var button of buttons) { + button.isActive = (button.value === value); } } diff --git a/src/components/select/select.ts b/src/components/select/select.ts index ea33f9b0d33..da5047193d8 100644 --- a/src/components/select/select.ts +++ b/src/components/select/select.ts @@ -1,4 +1,4 @@ -import { AfterViewInit, Component, ContentChildren, ElementRef, EventEmitter, Input, HostListener, OnDestroy, Optional, Output, Renderer, QueryList, ViewEncapsulation } from '@angular/core'; +import { Component, ContentChildren, ElementRef, EventEmitter, Input, HostListener, OnDestroy, Optional, Output, Renderer, QueryList, ViewEncapsulation } from '@angular/core'; import { NG_VALUE_ACCESSOR } from '@angular/forms'; import { ActionSheet } from '../action-sheet/action-sheet'; @@ -147,7 +147,7 @@ import { SelectPopover, SelectPopoverOption } from './select-popover-component'; providers: [ { provide: NG_VALUE_ACCESSOR, useExisting: Select, multi: true } ], encapsulation: ViewEncapsulation.None, }) -export class Select extends BaseInput implements AfterViewInit, OnDestroy { +export class Select extends BaseInput implements OnDestroy { _multi: boolean = false; _options: QueryList